8000 SET_POSITION_TARGET_LOCAL_NED (84) · Issue #612 · mavlink/mavlink-devguide · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
SET_POSITION_TARGET_LOCAL_NED (84) #612
Open
@KKJava1

Description

@KKJava1

Now,Already receive setMode method and control uav move. However, the steering function is not currently available.

    public void droneControl(String sn, float x, float y, float h, float w) throws Exception {
        isConnection(sn);
        
        setOldUavMode(sn, 1);  // change offboard mode
        
        float currentYawRad = 0.0f;
        if (w != 0) {
            UavDataCacheManager cacheManager = UavDataCacheManager.getInstance();
            Map<String, Object> uavDataBySn = cacheManager.getUavDataBySn(sn);
            if (ObjectUtil.isNotEmpty(uavDataBySn) && ObjectUtil.isNotEmpty(uavDataBySn.get("yaw"))) {
                currentYawRad = (float) uavDataBySn.get("yaw");
            }
            float deltaYaw = (float) Math.toRadians(-w); // Convert degrees to radians
            currentYawRad += deltaYaw;
            currentYawRad = (float) ((currentYawRad + Math.PI) % (2 * Math.PI) - Math.PI);
        }
        MavlinkUav uav = getMavlinkUav(sn);

        SetPositionTargetLocalNed message = SetPositionTargetLocalNed.builder()
                .targetSystem(uav.getTargetSystem())
                .targetComponent(uav.getTargetComponent())
                .coordinateFrame(MavFrame.MAV_FRAME_BODY_FRD)
                .typeMask(PositionTargetTypemask.POSITION_TARGET_TYPEMASK_VX_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_VY_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_VZ_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_AX_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_AY_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_AZ_IGNORE,
                        PositionTargetTypemask.POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE)
                .x(x)
                .y(y)
                .z(-h)
                .vx(0.0f)
                .vy(0.0f)
                .vz(0.0f)
                .afx(0.0f)
                .afy(0.0f)
                .afz(0.0f)
                .yaw(currentYawRad)
                .yawRate(0.0f)
                .build();
        
        MavlinkConnection connection = uav.getMavlinkConnection();
        logger.info("The command sent by the command flight is", message);
        connection.send2(
                uav.getTargetSystem(),
                uav.getTargetComponent(),
                message);
    }

This method can be used to control the movement of the drone, including up, down, left, and right.But it cannot be redirected. The redirection log is as follows

2025-06-13 16:44:16.373 - [MQTT Call: re62834ba80076e952617679e966aa23b3][] INFO com.yuefei.uav.mavlink.service.MavlinkService -SetPositionTargetLocalNed{timeBootMs=0, targetSystem=6, targetComponent=1, coordinateFrame=EnumValue{value=12, entry=MAV_FRAME_BODY_FRD}, typeMask=EnumValue{value=2552, entry=null}, x=0.0, y=0.0, z=-0.0, vx=0.0, vy=0.0, vz=0.0, afx=0.0, afy=0.0, afz=0.0, yaw=-0.24230176, yawRate=0.0}

Is there something wrong with the method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0