|
发表于 2024-6-6 17:58:50
1080 浏览 1 回复
[飞控嵌入式]
mavlink协议控制jMAVSim仿真环境里面的无人机飞行,起飞不了
本帖最后由 16670150941 于 2024-6-7 09:08 编辑
使用c语言编写了一个示例UDP服务器,通过mavlink协议控制jMAVSim仿真环境里面的无人机飞行,进入offboard模式后,以4HZ频率不断发送设置点信息给无人机,仿真环境里面的无人机也能收到数据,但是就是起飞不了
接收解析到无人机的position_target_local_ned点坐标数据总是显示nan:xyz:[ nan, nan, nan ], vxyz:[ nan, nan, nan ]
不知道是哪里设置错误了,导致无人机自动退出offboard模式然后自动上锁
设置点的赋值如下:
```
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_POSITION 0b0000110111111000
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_VELOCITY 0b0000110111000111
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_ACCELERATION 0b0000110000111111
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_FORCE 0b0000111000111111
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_YAW_ANGLE 0b0000100111111111
#define MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_YAW_RATE 0b0000010111111111
mavlink_set_position_target_local_ned_t position_target
set_pos_ned.time_boot_ms = (uint32_t) (get_time_usec()/1000);
set_pos_ned.target_system = 1;
set_pos_ned.target_component = 1;
set_pos_ned.coordinate_frame = MAV_FRAME_LOCAL_NED;
set_pos_ned.type_mask = MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_POSITION & MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_VELOCITY;
set_pos_ned.x = 0;
set_pos_ned.y = 0;
set_pos_ned.z = -5;
set_pos_ned.vx = 1;
set_pos_ned.vy = 1;
set_pos_ned.vz = -1;
set_pos_ned.yaw = NAN;
set_pos_ned.yaw_rate = NAN;
我知道答案
回答被采纳将会获得 2 阿木币 已有1人回答
|
扫一扫浏览分享
|
|
|
|
|
|
|
发表于 2024-7-6 23:14:06
如果发送数据的频率不够,无人机是不会飞的,因为不足以支持无人机需要的控制频率。 |
|
|
|
|
|
|
|