aboutsummaryrefslogtreecommitdiff
path: root/src/examples/publisher
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2015-01-26 14:50:23 +0100
committerThomas Gubler <thomasgubler@gmail.com>2015-01-26 19:01:07 +0100
commitabeae7b6f6d70042c6b0bed493ade52727648c2d (patch)
tree548171e0583ade29721efcbd91310549e4fcfd25 /src/examples/publisher
parent8dbb1fc8d443b1f8e2e454d4b82051fa63a48398 (diff)
downloadpx4-firmware-abeae7b6f6d70042c6b0bed493ade52727648c2d.tar.gz
px4-firmware-abeae7b6f6d70042c6b0bed493ade52727648c2d.tar.bz2
px4-firmware-abeae7b6f6d70042c6b0bed493ade52727648c2d.zip
extend subscriber/publisher example
Diffstat (limited to 'src/examples/publisher')
-rw-r--r--src/examples/publisher/publisher_example.cpp25
-rw-r--r--src/examples/publisher/publisher_example.h2
2 files changed, 22 insertions, 5 deletions
diff --git a/src/examples/publisher/publisher_example.cpp b/src/examples/publisher/publisher_example.cpp
index 9952a16e4..e7ab9eb5a 100644
--- a/src/examples/publisher/publisher_example.cpp
+++ b/src/examples/publisher/publisher_example.cpp
@@ -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);
}
diff --git a/src/examples/publisher/publisher_example.h b/src/examples/publisher/publisher_example.h
index 4ff59a226..8165b0ffc 100644
--- a/src/examples/publisher/publisher_example.h
+++ b/src/examples/publisher/publisher_example.h
@@ -50,4 +50,6 @@ public:
protected:
px4::NodeHandle _n;
px4::Publisher<px4::px4_rc_channels> * _rc_channels_pub;
+ px4::Publisher<px4::px4_vehicle_attitude> * _v_att_pub;
+ px4::Publisher<px4::px4_parameter_update> * _parameter_update_pub;
};