• 随时记录解决


    1. 设置gcs_link相关
    auto gcs_link = MAVConnInterface::open_url("udp-b://@");
    
    mavlink::common::msg::HEARTBEAT hb{};
    // fill hb
    
    gcs_link->send_message_ignore_drop(hb);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    1. 在mavros中send_message_ignore_drop 会调用fcu_link
    UAS_FCU(&mav_uas) = fcu_link;
    
    • 1
    1. gcs_link的时候,调用的是fcu_link发送
    if (gcs_link) {
    		// setup GCS link bridge
    		gcs_link->connect([this, fcu_link](const mavlink_message_t *msg, const Framing framing) {
    			this->last_message_received_from_gcs = ros::Time::now();
    			fcu_link->send_message_ignore_drop(msg);
    		});
    
    		gcs_link_diag.set_connection_status(true);
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    1. ros发送消息给QGC
      https://github.com/mavlink/mavros/issues/574
    #include 
    #include 
    #include 
    #include 
    
    // General parameters
    uint8_t system_id = 1;
    uint8_t component_id = 1;
    uint8_t type = 1;
    uint8_t autopilot = 0;
    uint8_t base_mode = 128;
    uint32_t custom_mode = 0;
    uint8_t system_status = 0;
    
    // Parameters of the altitude message
    float alt_monotonic = 10.0;
    float alt_amsl = 100;
    float alt_local = 10.0;
    float alt_relative = 10.0;
    float alt_terrain = 10;
    float bottom_clearance = 0;
    
    int main(int argc, char **argv){
    
        // Create heartbeat message
        mavlink_message_t msg_heartbeat;
        mavlink_msg_heartbeat_pack(system_id, component_id, &msg_heartbeat, type, autopilot, base_mode, custom_mode, system_status);
    
        mavros_msgs::Mavlink ml_heartbeat;
        mavros_msgs::mavlink::convert(msg_heartbeat, ml_heartbeat);
    
        // Create altitude message
        mavlink_message_t msg_altitude;
        mavros_msgs::Mavlink ml_altitude;
    
        ros::init(argc, argv, "telemetry_publisher");
        ros::NodeHandle n;
    
        ros::Publisher example_pub = n.advertise<mavros_msgs::Mavlink>("/mavlink/from", 1000);
        ros::Rate loop_rate(1); // 1 Hz
    
        while (ros::ok())
        {
            uint64_t time_stamp = ros::Time::now().nsec;
    
            // Finish altitude message
            mavlink_msg_altitude_pack(system_id, component_id, &msg_altitude, time_stamp, alt_monotonic, alt_amsl, alt_local, alt_relative, alt_terrain, bottom_clearance);
            mavros_msgs::mavlink::convert(msg_altitude, ml_altitude);
    
            // Publish messages
            example_pub.publish(ml_heartbeat);
            example_pub.publish(ml_altitude);
    
            ros::spinOnce();
            loop_rate.sleep();
        }
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
  • 相关阅读:
    Java日志系列——规范化日志
    【数据结构】时间复杂度和空间复杂度
    【项目设计】网络版五子棋游戏
    现代 Android 开发的第一步Kotlin
    换台电脑python使用uiautomator2操作逍遥模拟器
    Java延迟队列——DelayQueue
    【力客热题HOT100】-【038】96 不同的二叉搜索树
    [网鼎杯 2020 朱雀组]Nmap 通过nmap写入木马 argcmd过滤实现逃逸
    JAVAAPI实现血缘关系Rest推送到DataHub V0.12.1版本
    select在socket中的server多路复用
  • 原文地址:https://blog.csdn.net/weixin_45377028/article/details/127700692