mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 10:33:33 +08:00
mavlink: GPS_RAW_INT stream added
This commit is contained in:
@@ -839,69 +839,77 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//class MavlinkStreamGPSRawInt : public MavlinkStream
|
class MavlinkStreamGPSRawInt : public MavlinkStream
|
||||||
//{
|
{
|
||||||
//public:
|
public:
|
||||||
// const char *get_name() const
|
const char *get_name() const
|
||||||
// {
|
{
|
||||||
// return MavlinkStreamGPSRawInt::get_name_static();
|
return MavlinkStreamGPSRawInt::get_name_static();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// static const char *get_name_static()
|
static const char *get_name_static()
|
||||||
// {
|
{
|
||||||
// return "GPS_RAW_INT";
|
return "GPS_RAW_INT";
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// uint8_t get_id()
|
uint8_t get_id()
|
||||||
// {
|
{
|
||||||
// return MAVLINK_MSG_ID_GPS_RAW_INT;
|
return MAVLINK_MSG_ID_GPS_RAW_INT;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// static MavlinkStream *new_instance(Mavlink *mavlink)
|
static MavlinkStream *new_instance(Mavlink *mavlink)
|
||||||
// {
|
{
|
||||||
// return new MavlinkStreamGPSRawInt();
|
return new MavlinkStreamGPSRawInt(mavlink);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//private:
|
unsigned get_size()
|
||||||
// MavlinkOrbSubscription *gps_sub;
|
{
|
||||||
// uint64_t gps_time;
|
return MAVLINK_MSG_ID_GPS_RAW_INT_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES;
|
||||||
//
|
}
|
||||||
// /* do not allow top copying this class */
|
|
||||||
// MavlinkStreamGPSRawInt(MavlinkStreamGPSRawInt &);
|
private:
|
||||||
// MavlinkStreamGPSRawInt& operator = (const MavlinkStreamGPSRawInt &);
|
MavlinkOrbSubscription *_gps_sub;
|
||||||
//
|
uint64_t _gps_time;
|
||||||
//protected:
|
|
||||||
// explicit MavlinkStreamGPSRawInt() : MavlinkStream(),
|
/* do not allow top copying this class */
|
||||||
// gps_sub(nullptr),
|
MavlinkStreamGPSRawInt(MavlinkStreamGPSRawInt &);
|
||||||
// gps_time(0)
|
MavlinkStreamGPSRawInt& operator = (const MavlinkStreamGPSRawInt &);
|
||||||
// {}
|
|
||||||
//
|
protected:
|
||||||
// void subscribe()
|
explicit MavlinkStreamGPSRawInt(Mavlink *mavlink) : MavlinkStream(mavlink),
|
||||||
// {
|
_gps_sub(nullptr),
|
||||||
// gps_sub = _mavlink->add_orb_subscription(ORB_ID(vehicle_gps_position));
|
_gps_time(0)
|
||||||
// }
|
{}
|
||||||
//
|
|
||||||
// void send(const hrt_abstime t)
|
void subscribe()
|
||||||
// {
|
{
|
||||||
// struct vehicle_gps_position_s gps;
|
_gps_sub = _mavlink->add_orb_subscription(ORB_ID(vehicle_gps_position));
|
||||||
//
|
}
|
||||||
// if (gps_sub->update(&gps_time, &gps)) {
|
|
||||||
// mavlink_msg_gps_raw_int_send(_channel,
|
void send(const hrt_abstime t)
|
||||||
// gps.timestamp_position,
|
{
|
||||||
// gps.fix_type,
|
struct vehicle_gps_position_s gps;
|
||||||
// gps.lat,
|
|
||||||
// gps.lon,
|
if (_gps_sub->update(&_gps_time, &gps)) {
|
||||||
// gps.alt,
|
mavlink_gps_raw_int_t msg;
|
||||||
// cm_uint16_from_m_float(gps.eph),
|
|
||||||
// cm_uint16_from_m_float(gps.epv),
|
msg.time_usec = gps.timestamp_position;
|
||||||
// gps.vel_m_s * 100.0f,
|
msg.fix_type = gps.fix_type;
|
||||||
// _wrap_2pi(gps.cog_rad) * M_RAD_TO_DEG_F * 1e2f,
|
msg.lat = gps.lat;
|
||||||
// gps.satellites_used);
|
msg.lon = gps.lon;
|
||||||
// }
|
msg.alt = gps.alt;
|
||||||
// }
|
msg.eph = cm_uint16_from_m_float(gps.eph);
|
||||||
//};
|
msg.epv = cm_uint16_from_m_float(gps.epv);
|
||||||
//
|
msg.vel = cm_uint16_from_m_float(gps.vel_m_s),
|
||||||
//
|
msg.cog = _wrap_2pi(gps.cog_rad) * M_RAD_TO_DEG_F * 1e2f,
|
||||||
|
msg.satellites_visible = gps.satellites_used;
|
||||||
|
|
||||||
|
_mavlink->send_message(MAVLINK_MSG_ID_GPS_RAW_INT, &msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//class MavlinkStreamGlobalPositionInt : public MavlinkStream
|
//class MavlinkStreamGlobalPositionInt : public MavlinkStream
|
||||||
//{
|
//{
|
||||||
//public:
|
//public:
|
||||||
|
|||||||
Reference in New Issue
Block a user