PX4 Firmware
PX4 Autopilot Software http://px4.io
MavlinkStream Class Referenceabstract

#include <mavlink_stream.h>

Inherits ListNode< MavlinkStream *>.

Inherited by MavlinkStreamActuatorControlTarget< N >, MavlinkStreamADSBVehicle, MavlinkStreamAltitude, MavlinkStreamAttitude, MavlinkStreamAttitudeQuaternion, MavlinkStreamAttitudeTarget, MavlinkStreamAttPosMocap, MavlinkStreamBatteryStatus, MavlinkStreamCameraCapture, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamCollision, MavlinkStreamCommandLong, MavlinkStreamDebug, MavlinkStreamDebugFloatArray, MavlinkStreamDebugVect, MavlinkStreamDistanceSensor, MavlinkStreamEstimatorStatus, MavlinkStreamExtendedSysState, MavlinkStreamGlobalPositionInt, MavlinkStreamGPS2Raw, MavlinkStreamGPSRawInt, MavlinkStreamGroundTruth, MavlinkStreamHeartbeat, MavlinkStreamHighLatency2, MavlinkStreamHighresIMU, MavlinkStreamHILActuatorControls, MavlinkStreamHomePosition, MavlinkStreamLocalPositionNED, MavlinkStreamLocalPositionSetpoint, MavlinkStreamManualControl, MavlinkStreamMountOrientation, MavlinkStreamNamedValueFloat, MavlinkStreamNavControllerOutput, MavlinkStreamObstacleDistance, MavlinkStreamOdometry, MavlinkStreamOpticalFlowRad, MavlinkStreamOrbitStatus, MavlinkStreamPing, MavlinkStreamPositionTargetGlobalInt, MavlinkStreamRCChannels, MavlinkStreamScaledIMU, MavlinkStreamScaledIMU2, MavlinkStreamScaledIMU3, MavlinkStreamServoOutputRaw< N >, MavlinkStreamStatustext, MavlinkStreamSysStatus, MavlinkStreamSystemTime, MavlinkStreamTimesync, MavlinkStreamTrajectoryRepresentationWaypoints, MavlinkStreamUTMGlobalPosition, MavlinkStreamVFRHUD, and MavlinkStreamWind.

Collaboration diagram for MavlinkStream:

Public Member Functions

 MavlinkStream (Mavlink *mavlink)
 
virtual ~MavlinkStream ()=default
 
 MavlinkStream (const MavlinkStream &)=delete
 
MavlinkStreamoperator= (const MavlinkStream &)=delete
 
 MavlinkStream (MavlinkStream &&)=delete
 
MavlinkStreamoperator= (MavlinkStream &&)=delete
 
void set_interval (const int interval)
 Get the interval. More...
 
int get_interval ()
 Get the interval. More...
 
int update (const hrt_abstime &t)
 Update subscriptions and send message if necessary. More...
 
virtual const char * get_name () const =0
 
virtual uint16_t get_id ()=0
 
virtual bool const_rate ()
 
virtual unsigned get_size ()=0
 Get maximal total messages size on update. More...
 
virtual unsigned get_size_avg ()
 Get the average message size. More...
 
bool first_message_sent () const
 
void reset_last_sent ()
 Reset the time of last sent to 0. More...
 
- Public Member Functions inherited from ListNode< MavlinkStream *>
void setSibling (MavlinkStream * sibling)
 
const MavlinkStreamgetSibling () const
 

Protected Member Functions

virtual bool send (const hrt_abstime t)=0
 
virtual void update_data ()
 Function to collect/update data for the streams at a high rate independant of actual stream rate. More...
 

Protected Attributes

Mavlink *const _mavlink
 
int _interval {1000000}
 if set to negative value = unlimited rate More...
 
- Protected Attributes inherited from ListNode< MavlinkStream *>
MavlinkStream_list_node_sibling
 

Private Attributes

hrt_abstime _last_sent {0}
 
bool _first_message_sent {false}
 

Detailed Description

Definition at line 50 of file mavlink_stream.h.

Constructor & Destructor Documentation

◆ MavlinkStream() [1/3]

MavlinkStream::MavlinkStream ( Mavlink mavlink)

Definition at line 47 of file mavlink_stream.cpp.

References _last_sent, and hrt_absolute_time().

Here is the call graph for this function:

◆ ~MavlinkStream()

virtual MavlinkStream::~MavlinkStream ( )
virtualdefault

◆ MavlinkStream() [2/3]

MavlinkStream::MavlinkStream ( const MavlinkStream )
delete

◆ MavlinkStream() [3/3]

MavlinkStream::MavlinkStream ( MavlinkStream &&  )
delete

Member Function Documentation

◆ const_rate()

virtual bool MavlinkStream::const_rate ( )
inlinevirtual
Returns
true if steam rate shouldn't be adjusted

Reimplemented in MavlinkStreamPing, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamUTMGlobalPosition, MavlinkStreamADSBVehicle, MavlinkStreamHeartbeat, and MavlinkStreamHighLatency2.

Definition at line 88 of file mavlink_stream.h.

References get_size().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first_message_sent()

bool MavlinkStream::first_message_sent ( ) const
inline
Returns
true if the first message of this stream has been sent

Definition at line 108 of file mavlink_stream.h.

References _first_message_sent.

◆ get_id()

virtual uint16_t MavlinkStream::get_id ( )
pure virtual

Implemented in MavlinkStreamObstacleDistance, MavlinkStreamOrbitStatus, MavlinkStreamPing, MavlinkStreamGroundTruth, MavlinkStreamMountOrientation, MavlinkStreamWind, MavlinkStreamAltitude, MavlinkStreamExtendedSysState, MavlinkStreamDistanceSensor, MavlinkStreamCameraCapture, MavlinkStreamNavControllerOutput, MavlinkStreamDebugFloatArray, MavlinkStreamDebugVect, MavlinkStreamDebug, MavlinkStreamNamedValueFloat, MavlinkStreamOpticalFlowRad, MavlinkStreamTrajectoryRepresentationWaypoints, MavlinkStreamManualControl, MavlinkStreamRCChannels, MavlinkStreamAttitudeTarget, MavlinkStreamLocalPositionSetpoint, MavlinkStreamPositionTargetGlobalInt, MavlinkStreamHILActuatorControls, MavlinkStreamActuatorControlTarget< N >, MavlinkStreamServoOutputRaw< N >, MavlinkStreamHomePosition, MavlinkStreamAttPosMocap, MavlinkStreamEstimatorStatus, MavlinkStreamLocalPositionNED, MavlinkStreamOdometry, MavlinkStreamGlobalPositionInt, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamCollision, MavlinkStreamUTMGlobalPosition, MavlinkStreamADSBVehicle, MavlinkStreamTimesync, MavlinkStreamSystemTime, MavlinkStreamGPS2Raw, MavlinkStreamGPSRawInt, MavlinkStreamVFRHUD, MavlinkStreamAttitudeQuaternion, MavlinkStreamAttitude, MavlinkStreamScaledIMU3, MavlinkStreamScaledIMU2, MavlinkStreamScaledIMU, MavlinkStreamHighresIMU, MavlinkStreamBatteryStatus, MavlinkStreamSysStatus, MavlinkStreamCommandLong, MavlinkStreamStatustext, MavlinkStreamHeartbeat, and MavlinkStreamHighLatency2.

Referenced by get_interval().

Here is the caller graph for this function:

◆ get_interval()

int MavlinkStream::get_interval ( )
inline

Get the interval.

Returns
the inveral in microseconds (us) between messages

Definition at line 76 of file mavlink_stream.h.

References _interval, get_id(), get_name(), hrt_abstime, and update().

Here is the call graph for this function:

◆ get_name()

virtual const char* MavlinkStream::get_name ( ) const
pure virtual

Implemented in MavlinkStreamObstacleDistance, MavlinkStreamOrbitStatus, MavlinkStreamPing, MavlinkStreamGroundTruth, MavlinkStreamMountOrientation, MavlinkStreamWind, MavlinkStreamAltitude, MavlinkStreamExtendedSysState, MavlinkStreamDistanceSensor, MavlinkStreamCameraCapture, MavlinkStreamNavControllerOutput, MavlinkStreamDebugFloatArray, MavlinkStreamDebugVect, MavlinkStreamDebug, MavlinkStreamNamedValueFloat, MavlinkStreamOpticalFlowRad, MavlinkStreamTrajectoryRepresentationWaypoints, MavlinkStreamManualControl, MavlinkStreamRCChannels, MavlinkStreamAttitudeTarget, MavlinkStreamLocalPositionSetpoint, MavlinkStreamPositionTargetGlobalInt, MavlinkStreamHILActuatorControls, MavlinkStreamActuatorControlTarget< N >, MavlinkStreamServoOutputRaw< N >, MavlinkStreamHomePosition, MavlinkStreamAttPosMocap, MavlinkStreamEstimatorStatus, MavlinkStreamLocalPositionNED, MavlinkStreamOdometry, MavlinkStreamGlobalPositionInt, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamCollision, MavlinkStreamUTMGlobalPosition, MavlinkStreamADSBVehicle, MavlinkStreamTimesync, MavlinkStreamSystemTime, MavlinkStreamGPS2Raw, MavlinkStreamGPSRawInt, MavlinkStreamVFRHUD, MavlinkStreamAttitudeQuaternion, MavlinkStreamAttitude, MavlinkStreamScaledIMU3, MavlinkStreamScaledIMU2, MavlinkStreamScaledIMU, MavlinkStreamHighresIMU, MavlinkStreamBatteryStatus, MavlinkStreamSysStatus, MavlinkStreamCommandLong, MavlinkStreamStatustext, MavlinkStreamHeartbeat, and MavlinkStreamHighLatency2.

Referenced by get_interval().

Here is the caller graph for this function:

◆ get_size()

virtual unsigned MavlinkStream::get_size ( )
pure virtual

Get maximal total messages size on update.

Implemented in MavlinkStreamObstacleDistance, MavlinkStreamOrbitStatus, MavlinkStreamPing, MavlinkStreamGroundTruth, MavlinkStreamMountOrientation, MavlinkStreamWind, MavlinkStreamAltitude, MavlinkStreamExtendedSysState, MavlinkStreamDistanceSensor, MavlinkStreamCameraCapture, MavlinkStreamNavControllerOutput, MavlinkStreamDebugFloatArray, MavlinkStreamDebugVect, MavlinkStreamDebug, MavlinkStreamNamedValueFloat, MavlinkStreamOpticalFlowRad, MavlinkStreamTrajectoryRepresentationWaypoints, MavlinkStreamManualControl, MavlinkStreamRCChannels, MavlinkStreamAttitudeTarget, MavlinkStreamLocalPositionSetpoint, MavlinkStreamPositionTargetGlobalInt, MavlinkStreamHILActuatorControls, MavlinkStreamActuatorControlTarget< N >, MavlinkStreamServoOutputRaw< N >, MavlinkStreamHomePosition, MavlinkStreamAttPosMocap, MavlinkStreamEstimatorStatus, MavlinkStreamLocalPositionNED, MavlinkStreamOdometry, MavlinkStreamGlobalPositionInt, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamCollision, MavlinkStreamUTMGlobalPosition, MavlinkStreamADSBVehicle, MavlinkStreamTimesync, MavlinkStreamSystemTime, MavlinkStreamGPS2Raw, MavlinkStreamGPSRawInt, MavlinkStreamVFRHUD, MavlinkStreamAttitudeQuaternion, MavlinkStreamAttitude, MavlinkStreamScaledIMU3, MavlinkStreamScaledIMU2, MavlinkStreamScaledIMU, MavlinkStreamHighresIMU, MavlinkStreamBatteryStatus, MavlinkStreamSysStatus, MavlinkStreamCommandLong, MavlinkStreamStatustext, MavlinkStreamHeartbeat, and MavlinkStreamHighLatency2.

Referenced by const_rate(), and get_size_avg().

Here is the caller graph for this function:

◆ get_size_avg()

virtual unsigned MavlinkStream::get_size_avg ( )
inlinevirtual

Get the average message size.

For a normal stream this equals the message size, for something like a parameter or mission message this equals usually zero, as no bandwidth needs to be reserved

Definition at line 103 of file mavlink_stream.h.

References get_size().

Here is the call graph for this function:

◆ operator=() [1/2]

MavlinkStream& MavlinkStream::operator= ( const MavlinkStream )
delete

◆ operator=() [2/2]

MavlinkStream& MavlinkStream::operator= ( MavlinkStream &&  )
delete

◆ reset_last_sent()

void MavlinkStream::reset_last_sent ( )
inline

Reset the time of last sent to 0.

Can be used if a message over this stream needs to be sent immediately.

Definition at line 114 of file mavlink_stream.h.

References _last_sent.

Referenced by MavlinkStreamHighLatency2::MavlinkStreamHighLatency2().

Here is the caller graph for this function:

◆ send()

virtual bool MavlinkStream::send ( const hrt_abstime  t)
protectedpure virtual

Implemented in MavlinkStreamObstacleDistance, MavlinkStreamOrbitStatus, MavlinkStreamPing, MavlinkStreamGroundTruth, MavlinkStreamMountOrientation, MavlinkStreamWind, MavlinkStreamAltitude, MavlinkStreamExtendedSysState, MavlinkStreamDistanceSensor, MavlinkStreamCameraCapture, MavlinkStreamNavControllerOutput, MavlinkStreamDebugFloatArray, MavlinkStreamDebugVect, MavlinkStreamDebug, MavlinkStreamNamedValueFloat, MavlinkStreamOpticalFlowRad, MavlinkStreamTrajectoryRepresentationWaypoints, MavlinkStreamManualControl, MavlinkStreamRCChannels, MavlinkStreamAttitudeTarget, MavlinkStreamLocalPositionSetpoint, MavlinkStreamPositionTargetGlobalInt, MavlinkStreamHILActuatorControls, MavlinkStreamActuatorControlTarget< N >, MavlinkStreamServoOutputRaw< N >, MavlinkStreamHomePosition, MavlinkStreamAttPosMocap, MavlinkStreamEstimatorStatus, MavlinkStreamLocalPositionNED, MavlinkStreamOdometry, MavlinkStreamGlobalPositionInt, MavlinkStreamCameraImageCaptured, MavlinkStreamCameraTrigger, MavlinkStreamCollision, MavlinkStreamUTMGlobalPosition, MavlinkStreamADSBVehicle, MavlinkStreamTimesync, MavlinkStreamSystemTime, MavlinkStreamGPS2Raw, MavlinkStreamGPSRawInt, MavlinkStreamVFRHUD, MavlinkStreamAttitudeQuaternion, MavlinkStreamAttitude, MavlinkStreamScaledIMU3, MavlinkStreamScaledIMU2, MavlinkStreamScaledIMU, MavlinkStreamHighresIMU, MavlinkStreamBatteryStatus, MavlinkStreamSysStatus, MavlinkStreamCommandLong, MavlinkStreamStatustext, MavlinkStreamHeartbeat, and MavlinkStreamHighLatency2.

Referenced by update().

Here is the caller graph for this function:

◆ set_interval()

void MavlinkStream::set_interval ( const int  interval)
inline

Get the interval.

Parameters
intervalthe interval in microseconds (us) between messages

Definition at line 69 of file mavlink_stream.h.

References _interval.

Referenced by Mavlink::configure_stream().

Here is the caller graph for this function:

◆ update()

int MavlinkStream::update ( const hrt_abstime t)

Update subscriptions and send message if necessary.

Returns
0 if updated / sent, -1 if unchanged

Definition at line 57 of file mavlink_stream.cpp.

References _first_message_sent, _interval, _last_sent, _mavlink, const_rate(), dt, Mavlink::get_main_loop_delay(), Mavlink::get_rate_mult(), hrt_absolute_time(), send(), and update_data().

Referenced by get_interval(), MavlinkStreamSysStatus::send(), and MavlinkStreamBatteryStatus::send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_data()

virtual void MavlinkStream::update_data ( )
inlineprotectedvirtual

Function to collect/update data for the streams at a high rate independant of actual stream rate.

This function is called at every iteration of the mavlink module.

Reimplemented in MavlinkStreamHighLatency2.

Definition at line 128 of file mavlink_stream.h.

Referenced by update().

Here is the caller graph for this function:

Member Data Documentation

◆ _first_message_sent

bool MavlinkStream::_first_message_sent {false}
private

Definition at line 132 of file mavlink_stream.h.

Referenced by first_message_sent(), and update().

◆ _interval

int MavlinkStream::_interval {1000000}
protected

if set to negative value = unlimited rate

Definition at line 118 of file mavlink_stream.h.

Referenced by get_interval(), set_interval(), and update().

◆ _last_sent

hrt_abstime MavlinkStream::_last_sent {0}
private

Definition at line 131 of file mavlink_stream.h.

Referenced by MavlinkStream(), reset_last_sent(), and update().

◆ _mavlink

Mavlink* const MavlinkStream::_mavlink
protected

Definition at line 117 of file mavlink_stream.h.

Referenced by MavlinkStreamStatustext::get_size(), MavlinkStreamActuatorControlTarget< N >::MavlinkStreamActuatorControlTarget(), MavlinkStreamBatteryStatus::MavlinkStreamBatteryStatus(), MavlinkStreamHighLatency2::MavlinkStreamHighLatency2(), MavlinkStreamSysStatus::MavlinkStreamSysStatus(), MavlinkStreamHighLatency2::send(), MavlinkStreamHeartbeat::send(), MavlinkStreamStatustext::send(), MavlinkStreamCommandLong::send(), MavlinkStreamSysStatus::send(), MavlinkStreamBatteryStatus::send(), MavlinkStreamHighresIMU::send(), MavlinkStreamScaledIMU::send(), MavlinkStreamScaledIMU2::send(), MavlinkStreamScaledIMU3::send(), MavlinkStreamAttitude::send(), MavlinkStreamAttitudeQuaternion::send(), MavlinkStreamVFRHUD::send(), MavlinkStreamGPSRawInt::send(), MavlinkStreamGPS2Raw::send(), MavlinkStreamSystemTime::send(), MavlinkStreamTimesync::send(), MavlinkStreamADSBVehicle::send(), MavlinkStreamUTMGlobalPosition::send(), MavlinkStreamCollision::send(), MavlinkStreamCameraTrigger::send(), MavlinkStreamCameraImageCaptured::send(), MavlinkStreamGlobalPositionInt::send(), MavlinkStreamOdometry::send(), MavlinkStreamLocalPositionNED::send(), MavlinkStreamEstimatorStatus::send(), MavlinkStreamAttPosMocap::send(), MavlinkStreamHomePosition::send(), MavlinkStreamServoOutputRaw< N >::send(), MavlinkStreamActuatorControlTarget< N >::send(), MavlinkStreamHILActuatorControls::send(), MavlinkStreamPositionTargetGlobalInt::send(), MavlinkStreamLocalPositionSetpoint::send(), MavlinkStreamAttitudeTarget::send(), MavlinkStreamRCChannels::send(), MavlinkStreamManualControl::send(), MavlinkStreamTrajectoryRepresentationWaypoints::send(), MavlinkStreamOpticalFlowRad::send(), MavlinkStreamNamedValueFloat::send(), MavlinkStreamDebug::send(), MavlinkStreamDebugVect::send(), MavlinkStreamDebugFloatArray::send(), MavlinkStreamNavControllerOutput::send(), MavlinkStreamCameraCapture::send(), MavlinkStreamDistanceSensor::send(), MavlinkStreamExtendedSysState::send(), MavlinkStreamAltitude::send(), MavlinkStreamWind::send(), MavlinkStreamMountOrientation::send(), MavlinkStreamGroundTruth::send(), MavlinkStreamPing::send(), MavlinkStreamOrbitStatus::send(), MavlinkStreamObstacleDistance::send(), and update().


The documentation for this class was generated from the following files: