mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 13:03:34 +08:00
mavlink: publish RAW_RPM
This commit is contained in:
@@ -1594,6 +1594,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("PING", 0.1f);
|
||||
configure_stream_local("POSITION_TARGET_GLOBAL_INT", 1.0f);
|
||||
configure_stream_local("POSITION_TARGET_LOCAL_NED", 1.5f);
|
||||
configure_stream_local("RAW_RPM", 2.0f);
|
||||
configure_stream_local("RC_CHANNELS", 5.0f);
|
||||
configure_stream_local("SERVO_OUTPUT_RAW_0", 1.0f);
|
||||
configure_stream_local("SYS_STATUS", 1.0f);
|
||||
@@ -1640,6 +1641,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("PING", 1.0f);
|
||||
configure_stream_local("POSITION_TARGET_GLOBAL_INT", 10.0f);
|
||||
configure_stream_local("POSITION_TARGET_LOCAL_NED", 10.0f);
|
||||
configure_stream_local("RAW_RPM", 5.0f);
|
||||
configure_stream_local("RC_CHANNELS", 20.0f);
|
||||
configure_stream_local("SERVO_OUTPUT_RAW_0", 10.0f);
|
||||
configure_stream_local("SYS_STATUS", 5.0f);
|
||||
@@ -1760,6 +1762,7 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream)
|
||||
configure_stream_local("ORBIT_EXECUTION_STATUS", 5.0f);
|
||||
configure_stream_local("PING", 1.0f);
|
||||
configure_stream_local("POSITION_TARGET_GLOBAL_INT", 10.0f);
|
||||
configure_stream_local("RAW_RPM", 5.0f);
|
||||
configure_stream_local("RC_CHANNELS", 10.0f);
|
||||
configure_stream_local("SCALED_IMU", 25.0f);
|
||||
configure_stream_local("SCALED_IMU2", 25.0f);
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
#include <uORB/topics/orbit_status.h>
|
||||
#include <uORB/topics/position_controller_status.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
#include <uORB/topics/rpm.h>
|
||||
#include <uORB/topics/sensor_baro.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
#include <uORB/topics/sensor_mag.h>
|
||||
@@ -5178,6 +5179,70 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MavlinkStreamRawRpm : public MavlinkStream
|
||||
{
|
||||
public:
|
||||
const char *get_name() const override
|
||||
{
|
||||
return MavlinkStreamRawRpm::get_name_static();
|
||||
}
|
||||
|
||||
static constexpr const char *get_name_static()
|
||||
{
|
||||
return "RAW_RPM";
|
||||
}
|
||||
|
||||
static constexpr uint16_t get_id_static()
|
||||
{
|
||||
return MAVLINK_MSG_ID_RAW_RPM;
|
||||
}
|
||||
|
||||
uint16_t get_id() override
|
||||
{
|
||||
return get_id_static();
|
||||
}
|
||||
|
||||
static MavlinkStream *new_instance(Mavlink *mavlink)
|
||||
{
|
||||
return new MavlinkStreamRawRpm(mavlink);
|
||||
}
|
||||
|
||||
unsigned get_size() override
|
||||
{
|
||||
return _rpm_sub.advertised() ? MAVLINK_MSG_ID_RAW_RPM + MAVLINK_NUM_NON_PAYLOAD_BYTES : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
uORB::Subscription _rpm_sub{ORB_ID(rpm)};
|
||||
|
||||
/* do not allow top copying this class */
|
||||
MavlinkStreamRawRpm(MavlinkStreamRawRpm &) = delete;
|
||||
MavlinkStreamRawRpm &operator = (const MavlinkStreamRawRpm &) = delete;
|
||||
|
||||
protected:
|
||||
explicit MavlinkStreamRawRpm(Mavlink *mavlink) : MavlinkStream(mavlink)
|
||||
{}
|
||||
|
||||
bool send(const hrt_abstime t) override
|
||||
{
|
||||
rpm_s rpm;
|
||||
|
||||
if (_rpm_sub.update(&rpm)) {
|
||||
mavlink_raw_rpm_t msg{};
|
||||
|
||||
msg.frequency = rpm.indicated_frequency_rpm;
|
||||
|
||||
mavlink_msg_raw_rpm_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>(),
|
||||
@@ -5241,7 +5306,8 @@ static const StreamListItem streams_list[] = {
|
||||
create_stream_list_item<MavlinkStreamAutopilotVersion>(),
|
||||
create_stream_list_item<MavlinkStreamProtocolVersion>(),
|
||||
create_stream_list_item<MavlinkStreamFlightInformation>(),
|
||||
create_stream_list_item<MavlinkStreamStorageInformation>()
|
||||
create_stream_list_item<MavlinkStreamStorageInformation>(),
|
||||
create_stream_list_item<MavlinkStreamRawRpm>()
|
||||
};
|
||||
|
||||
const char *get_stream_name(const uint16_t msg_id)
|
||||
|
||||
Reference in New Issue
Block a user