当前位置:   article > 正文

使用PX4+T265+Jetson Nano实现无人机室内定点飞行(问题集)_飞控定点模式失效

飞控定点模式失效

问题描述:可进入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)

  1. /**
  2. * @file offb_node.cpp
  3. * @brief Offboard control example node, written with MAVROS version 0.19.x, PX4 Pro Flight
  4. * Stack and tested in Gazebo Classic SITL
  5. */
  6. #include <ros/ros.h>
  7. #include <geometry_msgs/PoseStamped.h>
  8. #include <mavros_msgs/CommandBool.h>
  9. #include <mavros_msgs/SetMode.h>
  10. #include <mavros_msgs/State.h>
  11. mavros_msgs::State current_state;
  12. void state_cb(const mavros_msgs::State::ConstPtr& msg){
  13. current_state = *msg;
  14. }
  15. int main(int argc, char **argv)
  16. {
  17. ros::init(argc, argv, "offb_node");
  18. ros::NodeHandle nh;
  19. ros::Subscriber state_sub = nh.subscribe<mavros_msgs::State>
  20. ("mavros/state", 10, state_cb);
  21. ros::Publisher local_pos_pub = nh.advertise<geometry_msgs::PoseStamped>
  22. ("mavros/setpoint_position/local", 10);
  23. ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>
  24. ("mavros/cmd/arming");
  25. ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>
  26. ("mavros/set_mode");
  27. //the setpoint publishing rate MUST be faster than 2Hz
  28. ros::Rate rate(20.0);
  29. // wait for FCU connection
  30. while(ros::ok() && !current_state.connected){
  31. ros::spinOnce();
  32. rate.sleep();
  33. }
  34. geometry_msgs::PoseStamped pose;
  35. pose.pose.position.x = 0;
  36. pose.pose.position.y = 0;
  37. pose.pose.position.z = 2;
  38. //send a few setpoints before starting
  39. for(int i = 100; ros::ok() && i > 0; --i){
  40. local_pos_pub.publish(pose);
  41. ros::spinOnce();
  42. rate.sleep();
  43. }
  44. mavros_msgs::SetMode offb_set_mode;
  45. offb_set_mode.request.custom_mode = "OFFBOARD";
  46. mavros_msgs::CommandBool arm_cmd;
  47. arm_cmd.request.value = true;
  48. ros::Time last_request = ros::Time::now();
  49. while(ros::ok()){
  50. if( current_state.mode != "OFFBOARD" &&
  51. (ros::Time::now() - last_request > ros::Duration(5.0))){
  52. if( set_mode_client.call(offb_set_mode) &&
  53. offb_set_mode.response.mode_sent){
  54. ROS_INFO("Offboard enabled");
  55. }
  56. last_request = ros::Time::now();
  57. } else {
  58. if( !current_state.armed &&
  59. (ros::Time::now() - last_request > ros::Duration(5.0))){
  60. if( arming_client.call(arm_cmd) &&
  61. arm_cmd.response.success){
  62. ROS_INFO("Vehicle armed");
  63. }
  64. last_request = ros::Time::now();
  65. }
  66. }
  67. local_pos_pub.publish(pose);
  68. ros::spinOnce();
  69. rate.sleep();
  70. }
  71. return 0;
  72. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/844938
推荐阅读
  

闽ICP备14008679号