【PX4_BUG】MAVROS控制无人机offboard模式无法起飞,报错CMD: Unexpected command 176, result 0,重复Offboard enabled

文章讲述了在使用MAVROS的offboard模式控制Gazebo中的飞机起飞时遇到的无法起飞问题,原因在于程序未接收到遥控器输入被视为不安全。通过修改COM_RCL_EXCEPT参数至4,解决了这个问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主要介绍在通过MAVROS功能包的offboard模式控制gazebo中的飞机起飞到高度两米时遇到无法起飞的BUG。

在运行过程中,可能会出现一个BUG,就是无人机无法起飞。

PX4源码处无人机gazebo仿真终端显示如下并不断重复。

INFO [commander] Failsafe mode deactivated
INFO [commander] Failsafe mode activated

在这里插入图片描述

MAVROS终端显示如下并不断重复。

CMD: Unexpected command 176, result 0

在这里插入图片描述

ROS节点终端显示如下并不断重复。

Offboard enabled

在这里插入图片描述

这时打开QGC地面站,可以看到无人机处于Not Ready状态。

在这里插入图片描述

并且有报错如下。

Failsafe enabled: No manual control stick input

在这里插入图片描述

分析原因是因为程序判断没有接入遥控器,认为不安全,所以不允许起飞。

解决方法为:

在前面的三个终端运行的时候,打开QGC地面站,在参数中搜索COM_RCL_EXCEPT

在这里插入图片描述

COM_RCL_EXCEPT参数改为4并保存。

在这里插入图片描述

这时回到gazebo窗口会发现飞机已经正常起飞了。


参考资料:

三、MAVROS功能包的offboard模式控制例子

MAVROS Offboard control example (C++)

如何进行基于ros_gazebo与px4的无人机仿真?

更正这个Python代码import rospy from mavros_msgs.msg import State from mavros_msgs.srv import CommandBool, SetMode from geometry_msgs.msg import PoseStamped import time current_state = State() def state_cb(msg): global current_state current_state = msg rospy.init_node('position') rate = rospy.Rate(20.0) state_sub = rospy.Subscriber("mavros/state", State, state_cb) local_pos_pub = rospy.Publisher("mavros/setpoint_position/local", PoseStamped, queue_size=10) arming_client = rospy.ServiceProxy("mavros/cmd/arming", CommandBool) set_mode_client = rospy.ServiceProxy("mavros/set_mode", SetMode) wait for FCU connection while not rospy.is_shutdown() and not current_state.connected: rate.sleep() pose = PoseStamped() pose.pose.position.x = 0 pose.pose.position.y = 0 pose.pose.position.z = 1.5 offb_set_mode = SetMode() offb_set_mode.custom_mode = "OFFBOARD" arm_cmd = CommandBool() arm_cmd.value = True state = 3 last_request = rospy.Time.now() while not rospy.is_shutdown() and (rospy.Time.now() - last_request < rospy.Duration(5.0)): if not current_state.armed: if arming_client(arm_cmd) and arm_cmd.response.success: rospy.loginfo("Vehicle armed") if current_state.mode != "OFFBOARD": if set_mode_client(offb_set_mode) and offb_set_mode.response.mode_sent: rospy.loginfo("Offboard enabled") rate.sleep() while state > 0: last_request = rospy.Time.now() while not rospy.is_shutdown() and (rospy.Time.now() - last_request < rospy.Duration(5.0)): pose.pose.position.x = 0 pose.pose.position.y = 0 local_pos_pub.publish(pose) rospy.loginfo("SUCCESS0") rate.sleep() last_request = rospy.Time.now() while not rospy.is_shutdown() and (rospy.Time.now() - last_request < rospy.Duration(5.0)): pose.pose.position.x = 2 pose.pose.position.y = 2 local_pos_pub.publish(pose) rospy.loginfo("SUCCESS1") rate.sleep() state -= 1 rospy.loginfo("state=" + str(state)) offb_set_mode.custom_mode = "AUTO.LAND" if set_mode_client(offb_set_mode) and offb_set_mode.response.mode_sent: rospy.loginfo("AUTO.LAND enabled") last_request = rospy.Time.now() rospy.spin()
06-13
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

后厂村路练习生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值