赞
踩
问题描述:可进入offboard模式,但无人机无法起飞。
现象:遥控器切自稳模式和定高模式(GPS闪蓝灯),遥控器可解锁;切到定点模式,GPS闪红灯,且地面站显示报错如下。
此时没有开启t265的ros节点,猜测飞控可能因为没有获取位置信息而报错。
随后开启t265和px4的ros节点。想获取位置的数据,在命令窗口输入:
rostopic echo /mavros/vision_pose/pose
发现并没有数据的输出。随后进行数据初始化,在命令窗口输入:
roslaunch vision_to_mavros t265_tf_to_mavros.launch
随后,前一个窗口开始获取数据。用遥控器切自稳、定高、定点模式,GPS均闪红灯。遥控器无法解锁。出现新的两个报错,分别是
FCU: Preflight Fail: Yaw estinate error
FCU: Preflight Faill: heading estinate not stable
但上述错误只在刚接入数据时出现。并且地面站无任何报错提示。不清楚错误是否为偶然性错误——有可能因刚接入数据不稳定才报错。
在一个无人机交流群提问,有大佬提示地面站要修改两个参数。(注意:PX4固件版本低于1.14,EKF2_AID_MASK参数才有效)
EKF2_AID_MASK = 24
EKF2_HGT_REF = Vision
若PX4固件版本为1.14及以后,EKF2_AID_MASK参数已弃用,转为EKF2_EV_CTRL进行设置
上述参数设置好后错误依然存在。
新的疑问:在地面站上看见的视觉里程计(t265)获取参数似乎不太正确,存在nan值。
尝试:想直接从自稳模式切到offboard模式, offboard模式可进,但是电机不转,且GPS边闪红灯边叫。
找到PX4的官方文档有关offboard部分代码示例。问题应该出在解锁部分。具体原因待定。
MAVROS Offboard control example (C++) | PX4 Guide (main)
- /**
- * @file offb_node.cpp
- * @brief Offboard control example node, written with MAVROS version 0.19.x, PX4 Pro Flight
- * Stack and tested in Gazebo Classic SITL
- */
-
- #include <ros/ros.h>
- #include <geometry_msgs/PoseStamped.h>
- #include <mavros_msgs/CommandBool.h>
- #include <mavros_msgs/SetMode.h>
- #include <mavros_msgs/State.h>
-
- mavros_msgs::State current_state;
- void state_cb(const mavros_msgs::State::ConstPtr& msg){
- current_state = *msg;
- }
-
- int main(int argc, char **argv)
- {
- ros::init(argc, argv, "offb_node");
- ros::NodeHandle nh;
-
- ros::Subscriber state_sub = nh.subscribe<mavros_msgs::State>
- ("mavros/state", 10, state_cb);
- ros::Publisher local_pos_pub = nh.advertise<geometry_msgs::PoseStamped>
- ("mavros/setpoint_position/local", 10);
- ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>
- ("mavros/cmd/arming");
- ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>
- ("mavros/set_mode");
-
- //the setpoint publishing rate MUST be faster than 2Hz
- ros::Rate rate(20.0);
-
- // wait for FCU connection
- while(ros::ok() && !current_state.connected){
- ros::spinOnce();
- rate.sleep();
- }
-
- geometry_msgs::PoseStamped pose;
- pose.pose.position.x = 0;
- pose.pose.position.y = 0;
- pose.pose.position.z = 2;
-
- //send a few setpoints before starting
- for(int i = 100; ros::ok() && i > 0; --i){
- local_pos_pub.publish(pose);
- ros::spinOnce();
- rate.sleep();
- }
-
- mavros_msgs::SetMode offb_set_mode;
- offb_set_mode.request.custom_mode = "OFFBOARD";
-
- mavros_msgs::CommandBool arm_cmd;
- arm_cmd.request.value = true;
-
- ros::Time last_request = ros::Time::now();
-
- while(ros::ok()){
- if( current_state.mode != "OFFBOARD" &&
- (ros::Time::now() - last_request > ros::Duration(5.0))){
- if( set_mode_client.call(offb_set_mode) &&
- offb_set_mode.response.mode_sent){
- ROS_INFO("Offboard enabled");
- }
- last_request = ros::Time::now();
- } else {
- if( !current_state.armed &&
- (ros::Time::now() - last_request > ros::Duration(5.0))){
- if( arming_client.call(arm_cmd) &&
- arm_cmd.response.success){
- ROS_INFO("Vehicle armed");
- }
- last_request = ros::Time::now();
- }
- }
-
- local_pos_pub.publish(pose);
-
- ros::spinOnce();
- rate.sleep();
- }
-
- return 0;
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。