mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-01 16:24:08 +08:00
mavlink: move RAW_RPM stream to separate file
This commit is contained in:
parent
9c4abf334b
commit
94146a7b16
@ -85,7 +85,6 @@
|
||||
#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_gps.h>
|
||||
#include <uORB/topics/sensor_mag.h>
|
||||
@ -123,6 +122,7 @@ using matrix::wrap_2pi;
|
||||
#include "streams/EXTENDED_SYS_STATE.hpp"
|
||||
#include "streams/FLIGHT_INFORMATION.hpp"
|
||||
#include "streams/PROTOCOL_VERSION.hpp"
|
||||
#include "streams/RAW_RPM.hpp"
|
||||
#include "streams/STORAGE_INFORMATION.hpp"
|
||||
|
||||
// ensure PX4 rotation enum and MAV_SENSOR_ROTATION align
|
||||
@ -5229,70 +5229,6 @@ 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>(),
|
||||
@ -5374,7 +5310,9 @@ static const StreamListItem streams_list[] = {
|
||||
#if defined(STORAGE_INFORMATION_HPP)
|
||||
create_stream_list_item<MavlinkStreamStorageInformation>(),
|
||||
#endif // STORAGE_INFORMATION_HPP
|
||||
#if defined(RAW_RPM_HPP)
|
||||
create_stream_list_item<MavlinkStreamRawRpm>()
|
||||
#endif // RAW_RPM_HPP
|
||||
};
|
||||
|
||||
const char *get_stream_name(const uint16_t msg_id)
|
||||
|
||||
78
src/modules/mavlink/streams/RAW_RPM.hpp
Normal file
78
src/modules/mavlink/streams/RAW_RPM.hpp
Normal file
@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef RAW_RPM_HPP
|
||||
#define RAW_RPM_HPP
|
||||
|
||||
#include <uORB/topics/rpm.h>
|
||||
|
||||
class MavlinkStreamRawRpm : public MavlinkStream
|
||||
{
|
||||
public:
|
||||
static MavlinkStream *new_instance(Mavlink *mavlink) { return new MavlinkStreamRawRpm(mavlink); }
|
||||
|
||||
static constexpr const char *get_name_static() { return "RAW_RPM"; }
|
||||
static constexpr uint16_t get_id_static() { return MAVLINK_MSG_ID_RAW_RPM; }
|
||||
|
||||
const char *get_name() const override { return get_name_static(); }
|
||||
uint16_t get_id() override { return get_id_static(); }
|
||||
|
||||
unsigned get_size() override
|
||||
{
|
||||
return _rpm_sub.advertised() ? MAVLINK_MSG_ID_RAW_RPM + MAVLINK_NUM_NON_PAYLOAD_BYTES : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MavlinkStreamRawRpm(Mavlink *mavlink) : MavlinkStream(mavlink) {}
|
||||
|
||||
uORB::Subscription _rpm_sub{ORB_ID(rpm)};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // RAW_RPM_HPP
|
||||
Loading…
x
Reference in New Issue
Block a user