examples/px4_simple_app: replace sensor_combined with vehicle_acceleration

This commit is contained in:
Daniel Agar
2020-08-23 17:38:27 -04:00
parent 1bb4c9d05f
commit e8a074dc03
+11 -11
View File
@@ -48,7 +48,7 @@
#include <math.h> #include <math.h>
#include <uORB/uORB.h> #include <uORB/uORB.h>
#include <uORB/topics/sensor_combined.h> #include <uORB/topics/vehicle_acceleration.h>
#include <uORB/topics/vehicle_attitude.h> #include <uORB/topics/vehicle_attitude.h>
__EXPORT int px4_simple_app_main(int argc, char *argv[]); __EXPORT int px4_simple_app_main(int argc, char *argv[]);
@@ -57,8 +57,8 @@ int px4_simple_app_main(int argc, char *argv[])
{ {
PX4_INFO("Hello Sky!"); PX4_INFO("Hello Sky!");
/* subscribe to sensor_combined topic */ /* subscribe to vehicle_acceleration topic */
int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined)); int sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
/* limit the update rate to 5 Hz */ /* limit the update rate to 5 Hz */
orb_set_interval(sensor_sub_fd, 200); orb_set_interval(sensor_sub_fd, 200);
@@ -99,20 +99,20 @@ int px4_simple_app_main(int argc, char *argv[])
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
/* obtained data for the first file descriptor */ /* obtained data for the first file descriptor */
struct sensor_combined_s raw; struct vehicle_acceleration_s accel;
/* copy sensors raw data into local buffer */ /* copy sensors raw data into local buffer */
orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw); orb_copy(ORB_ID(vehicle_acceleration), sensor_sub_fd, &accel);
PX4_INFO("Accelerometer:\t%8.4f\t%8.4f\t%8.4f", PX4_INFO("Accelerometer:\t%8.4f\t%8.4f\t%8.4f",
(double)raw.accelerometer_m_s2[0], (double)accel.xyz[0],
(double)raw.accelerometer_m_s2[1], (double)accel.xyz[1],
(double)raw.accelerometer_m_s2[2]); (double)accel.xyz[2]);
/* set att and publish this information for other apps /* set att and publish this information for other apps
the following does not have any meaning, it's just an example the following does not have any meaning, it's just an example
*/ */
att.q[0] = raw.accelerometer_m_s2[0]; att.q[0] = accel.xyz[0];
att.q[1] = raw.accelerometer_m_s2[1]; att.q[1] = accel.xyz[1];
att.q[2] = raw.accelerometer_m_s2[2]; att.q[2] = accel.xyz[2];
orb_publish(ORB_ID(vehicle_attitude), att_pub, &att); orb_publish(ORB_ID(vehicle_attitude), att_pub, &att);
} }