大疆社区

标题: 无人机怎么yaw转动 [打印本页]

作者: djiuser_2qce936    时间: 2020-7-23
标题: 无人机怎么yaw转动
无人机怎么yaw转动,调用什么api,FlightController().getState().setAttitude  好像没有效果啊

作者: paul zhou    时间: 2020-7-23
帮顶
作者: kv886    时间: 2020-7-23
要用虚拟摇杆virtual stick 的相关方法。
作者: LRQQQ    时间: 2020-7-24
setYawControlMode(YawControlMode.ANGULAR_VELOCITY)或者setYawControlMode(YawControlMode.ANGLE),直接给YAW赋值就好了。这个在官方的demo中有示例的
作者: djiuser_2qce936    时间: 2020-7-24
LRQQQOsmo Mobile 37-24 15:49
setYawControlMode(YawControlMode.ANGULAR_VELOCITY)或者setYawControlMode(YawControlMode.ANGLE),直接给YAW赋值就好了。这个在官方的demo中有示例的
您好  那我让它每次旋转90度,每次加90,超过180就改成(原角度+90)-360这样旋转    但是实际上他并没有完全按照设定的角度旋转,这是我的代码
    private void aircraftYaw(float angle){
        Attitude attitude = flightController.getState().getAttitude();
        float pitch = (float) attitude.pitch;
        float roll = (float) attitude.roll;
        float yaw = (float) attitude.yaw + angle;

        if (yaw > 180){
            yaw = yaw - 360;
        }

        flightController.sendVirtualStickFlightControlData
                (new FlightControlData(pitch, roll, yaw,0),
                        null);
    }
作者: djiuser_2qce936    时间: 2020-7-24
kv8867-23 19:52
要用虚拟摇杆virtual stick 的相关方法。
您好  那我让它每次旋转90度,每次加90,超过180就改成(原角度+90)-360这样旋转    但是实际上他并没有完全按照设定的角度旋转,这是我的代码
    private void aircraftYaw(float angle){
        Attitude attitude = flightController.getState().getAttitude();
        float pitch = (float) attitude.pitch;
        float roll = (float) attitude.roll;
        float yaw = (float) attitude.yaw + angle;

        if (yaw > 180){
            yaw = yaw - 360;
        }

        flightController.sendVirtualStickFlightControlData
                (new FlightControlData(pitch, roll, yaw,0),
                        null);
    }
作者: kv886    时间: 2020-7-24
djiuser_2qce9367-24 16:23
您好  那我让它每次旋转90度,每次加90,超过180就改成(原角度+90)-360这样旋转    但是实际上他并没有完全按照设定的角度旋转,这是我的代码
    private void aircraftYaw(float angle){
        Attitude attitude = flightController.getState().getAttitude();
        float pitch = (float) attitude.pitch;
        float roll = (float) attitude.roll;
        float yaw = (float) attitude.yaw + angle;

        if (yaw > 180){
            yaw = yaw - 360;
        }

        flightController.sendVirtualStickFlightControlData
                (new FlightControlData(pitch, roll, yaw,0),
                        null);
    }
这个命令不能只发一次,要以一定频率发送才可以,文档上有说明的。
作者: fansi    时间: 2021-8-7
djiuser_2qce936Phantom 4 Advanced2020-7-24 16:23
您好  那我让它每次旋转90度,每次加90,超过180就改成(原角度+90)-360这样旋转    但是实际上他并没有完全按照设定的角度旋转,这是我的代码
    private void aircraftYaw(float angle){
        Attitude attitude = flightController.getState().getAttitude();
        float pitch = (float) attitude.pitch;
        float roll = (float) attitude.roll;
        float yaw = (float) attitude.yaw + angle;

        if (yaw > 180){
            yaw = yaw - 360;
        }

        flightController.sendVirtualStickFlightControlData
                (new FlightControlData(pitch, roll, yaw,0),
                        null);
    }
大佬, 这个问题解决了么?  我也遇到同样的问题了




欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2