mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-14 13:21:36 +08:00
mavlink: move OBSTACLE_DISTANCE stream to separate file
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
#include <uORB/topics/mavlink_log.h>
|
||||
#include <uORB/topics/mount_orientation.h>
|
||||
#include <uORB/topics/obstacle_distance.h>
|
||||
#include <uORB/topics/optical_flow.h>
|
||||
#include <uORB/topics/orbit_status.h>
|
||||
#include <uORB/topics/position_controller_status.h>
|
||||
@@ -121,6 +120,7 @@ using matrix::wrap_2pi;
|
||||
#include "streams/EXTENDED_SYS_STATE.hpp"
|
||||
#include "streams/FLIGHT_INFORMATION.hpp"
|
||||
#include "streams/HIGH_LATENCY2.hpp"
|
||||
#include "streams/OBSTACLE_DISTANCE.hpp"
|
||||
#include "streams/PROTOCOL_VERSION.hpp"
|
||||
#include "streams/RAW_RPM.hpp"
|
||||
#include "streams/STORAGE_INFORMATION.hpp"
|
||||
@@ -5158,77 +5158,6 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
class MavlinkStreamObstacleDistance : public MavlinkStream
|
||||
{
|
||||
public:
|
||||
const char *get_name() const override
|
||||
{
|
||||
return MavlinkStreamObstacleDistance::get_name_static();
|
||||
}
|
||||
|
||||
static constexpr const char *get_name_static()
|
||||
{
|
||||
return "OBSTACLE_DISTANCE";
|
||||
}
|
||||
|
||||
static constexpr uint16_t get_id_static()
|
||||
{
|
||||
return MAVLINK_MSG_ID_OBSTACLE_DISTANCE;
|
||||
}
|
||||
|
||||
uint16_t get_id() override
|
||||
{
|
||||
return get_id_static();
|
||||
}
|
||||
|
||||
static MavlinkStream *new_instance(Mavlink *mavlink)
|
||||
{
|
||||
return new MavlinkStreamObstacleDistance(mavlink);
|
||||
}
|
||||
|
||||
unsigned get_size() override
|
||||
{
|
||||
return _obstacle_distance_fused_sub.advertised() ? (MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN +
|
||||
MAVLINK_NUM_NON_PAYLOAD_BYTES) : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
uORB::Subscription _obstacle_distance_fused_sub{ORB_ID(obstacle_distance_fused)};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamObstacleDistance(MavlinkStreamObstacleDistance &) = delete;
|
||||
MavlinkStreamObstacleDistance &operator = (const MavlinkStreamObstacleDistance &) = delete;
|
||||
|
||||
protected:
|
||||
explicit MavlinkStreamObstacleDistance(Mavlink *mavlink) : MavlinkStream(mavlink)
|
||||
{}
|
||||
|
||||
bool send() override
|
||||
{
|
||||
obstacle_distance_s obstacle_distance;
|
||||
|
||||
if (_obstacle_distance_fused_sub.update(&obstacle_distance)) {
|
||||
mavlink_obstacle_distance_t msg{};
|
||||
|
||||
msg.time_usec = obstacle_distance.timestamp;
|
||||
msg.sensor_type = obstacle_distance.sensor_type;
|
||||
memcpy(msg.distances, obstacle_distance.distances, sizeof(msg.distances));
|
||||
msg.increment = 0;
|
||||
msg.min_distance = obstacle_distance.min_distance;
|
||||
msg.max_distance = obstacle_distance.max_distance;
|
||||
msg.angle_offset = obstacle_distance.angle_offset;
|
||||
msg.increment_f = obstacle_distance.increment;
|
||||
msg.frame = obstacle_distance.frame;
|
||||
|
||||
mavlink_msg_obstacle_distance_send_struct(_mavlink->get_channel(), &msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
static const StreamListItem streams_list[] = {
|
||||
create_stream_list_item<MavlinkStreamHeartbeat>(),
|
||||
create_stream_list_item<MavlinkStreamStatustext>(),
|
||||
@@ -5293,7 +5222,9 @@ static const StreamListItem streams_list[] = {
|
||||
create_stream_list_item<MavlinkStreamGroundTruth>(),
|
||||
create_stream_list_item<MavlinkStreamPing>(),
|
||||
create_stream_list_item<MavlinkStreamOrbitStatus>(),
|
||||
#if defined(OBSTACLE_DISTANCE_HPP)
|
||||
create_stream_list_item<MavlinkStreamObstacleDistance>(),
|
||||
#endif // OBSTACLE_DISTANCE_HPP
|
||||
#if defined(ESC_INFO_HPP)
|
||||
create_stream_list_item<MavlinkStreamESCInfo>(),
|
||||
#endif // ESC_INFO_HPP
|
||||
|
||||
Reference in New Issue
Block a user