借用已有的Altitude
这个话题发布定高数据和基础油门估计
备注:v.1.11.3之后的PX4固件才加入了基础油门估计。
在src/modules/mavlink/mavlink_messages.cpp
的class MavlinkStreamAltitude : public MavlinkStream
函数里面
修改增加部分如下:
uORB::Subscription _local_pos_sub{ORB_ID(vehicle_local_position)};
uORB::Subscription _home_sub{ORB_ID(home_position)};
uORB::Subscription _air_data_sub{ORB_ID(vehicle_air_data)};
//wzy
uORB::Subscription _hover_thrust_estimate_sub{ORB_ID(hover_thrust_estimate)};
uORB::Subscription _distance_sensor_sub{ORB_ID(distance_sensor)};
/* do not allow top copying this class */
MavlinkStreamAltitude(MavlinkStreamAltitude &) = delete;
MavlinkStreamAltitude &operator = (const MavlinkStreamAltitude &) = delete;
以及
//wzy
hover_thrust_estimate_s thrust_estimate;
_hover_thrust_estimate_sub.copy(&thrust_estimate);
msg.altitude_amsl = thrust_estimate.hover_thrust;
//wzy
distance_sensor_s distanceSensor;
_distance_sensor_sub.copy(&distanceSensor);
msg.altitude_local = distanceSensor.current_distance;
// local position timeout after 10 ms
// avoid publishing only baro altitude_monotonic if possible
bool lpos_timeout = (hrt_elapsed_time(&local_pos.timestamp) > 10_ms);
if (lpos_updated || (air_data_updated && lpos_timeout)) {
msg.time_usec = hrt_absolute_time();
mavlink_msg_altitude_send_struct(_mavlink->get_channel(), &msg);
return true;
}
return false;
另外,为了增加该话题的发布速度,修改src/modules/mavlink/mavlink_main.cpp
的如下部分修改
case MAVLINK_MODE_ONBOARD:
// Note: streams requiring low latency come first
configure_stream_local("TIMESYNC", 10.0f);
configure_stream_local("CAMERA_TRIGGER", unlimited_rate);
configure_stream_local("HIGHRES_IMU", 50.0f);
configure_stream_local("LOCAL_POSITION_NED", 30.0f);
configure_stream_local("ATTITUDE", 100.0f);
// configure_stream_local("ALTITUDE", 10.0f);
configure_stream_local("ALTITUDE", 30.0f);//wzy
configure_stream_local("DISTANCE_SENSOR", 10.0f);
configure_stream_local("MOUNT_ORIENTATION", 10.0f);
configure_stream_local("OBSTACLE_DISTANCE", 10.0f);
configure_stream_local("ODOMETRY", 30.0f);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)