From https://pixhawk.org/dev/mavlink_and_uorb_custom_message?, I can see that the new class is defined as follows
class MavlinkStreamCaTrajectory : public MavlinkStream
{
public:
MavlinkStreamCaTrajectory() : MavlinkStream() { }
const char *get_name() { return “CA_TRAJECTORY”; } // this will be the name of the stream
MavlinkStream *new_instance() { return new MavlinkStreamCaTrajectory(); }
private:
MavlinkOrbSubscription *_sub;
struct ca_traj_struct_s *_msg;
protected:
void subscribe(Mavlink *mavlink)
{
_sub = mavlink->add_orb_subscription(ORB_ID(ca_trajectory_msg)); // make sure you enter the name of your uorb topic here
_msg = (struct ca_traj_struct_s *)_sub->get_data();
}
void send(const hrt_abstime t)
{
if (_sub->update(t)) {
mavlink_msg_ca_trajectory_send(_channel,
_msg->timestamp,
_msg->time_start_usec,
_msg->time_stop_usec,
_msg->coefficients,
_msg->seq_id);
}
}
};
while from the mavlink_messages.cpp file , I can see the new class is defined as these
class MavlinkStreamAttitude : public MavlinkStream
{
public:
const char *get_name() const
{
return MavlinkStreamAttitude::get_name_static();
}
static const char *get_name_static()
{
return "ATTITUDE";
}
uint8_t get_id()
{
return MAVLINK_MSG_ID_ATTITUDE;
}
static MavlinkStream *new_instance(Mavlink *mavlink)
{
return new MavlinkStreamAttitude(mavlink);
}
unsigned get_size()
{
return MAVLINK_MSG_ID_ATTITUDE_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES;
}
private:
MavlinkOrbSubscription *_att_sub;
uint64_t _att_time;
/* do not allow top copying
The format is so different, and I did what the tutorial said, and there occured a problem,
no matching function for call to ‘MavlinkStream::MavlinkStream()’
MavlinkStreamPMENV() : MavlinkStream() { }
Could anybody give me some advice?