mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 10:23:33 +08:00
extend subscriber/publisher example
This commit is contained in:
@@ -45,7 +45,9 @@ using namespace px4;
|
||||
|
||||
PublisherExample::PublisherExample() :
|
||||
_n(),
|
||||
_rc_channels_pub(_n.advertise<px4_rc_channels>())
|
||||
_rc_channels_pub(_n.advertise<px4_rc_channels>()),
|
||||
_v_att_pub(_n.advertise<px4_vehicle_attitude>()),
|
||||
_parameter_update_pub(_n.advertise<px4_parameter_update>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,10 +59,23 @@ int PublisherExample::main()
|
||||
loop_rate.sleep();
|
||||
_n.spinOnce();
|
||||
|
||||
px4_rc_channels msg;
|
||||
msg.data().timestamp_last_valid = px4::get_time_micros();
|
||||
PX4_INFO("%llu", msg.data().timestamp_last_valid);
|
||||
_rc_channels_pub->publish(msg);
|
||||
/* Publish example message */
|
||||
px4_rc_channels rc_channels_msg;
|
||||
rc_channels_msg.data().timestamp_last_valid = px4::get_time_micros();
|
||||
PX4_INFO("rc: %llu", rc_channels_msg.data().timestamp_last_valid);
|
||||
_rc_channels_pub->publish(rc_channels_msg);
|
||||
|
||||
/* Publish example message */
|
||||
px4_vehicle_attitude v_att_msg;
|
||||
v_att_msg.data().timestamp = px4::get_time_micros();
|
||||
PX4_INFO("att: %llu", v_att_msg.data().timestamp);
|
||||
_v_att_pub->publish(v_att_msg);
|
||||
|
||||
/* Publish example message */
|
||||
px4_parameter_update parameter_update_msg;
|
||||
parameter_update_msg.data().timestamp = px4::get_time_micros();
|
||||
PX4_INFO("param update: %llu", parameter_update_msg.data().timestamp);
|
||||
_parameter_update_pub->publish(parameter_update_msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user