mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-27 00:48:23 +08:00
docs(docs): Subscription handle is orb_sub_t type in example
This commit is contained in:
committed by
Ramon Roche
parent
a808eeec97
commit
d2df0a73e9
@@ -311,7 +311,7 @@ Subscribing to a topic is straightforward:
|
||||
```cpp
|
||||
#include <uORB/topics/vehicle_acceleration.h>
|
||||
..
|
||||
int sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
orb_sub_t sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
```
|
||||
|
||||
The `sensor_sub_fd` is a topic handle and can be used to very efficiently perform a blocking wait for new data.
|
||||
@@ -324,7 +324,7 @@ Adding `poll()` to the subscription looks like (_pseudocode, look for the full i
|
||||
#include <poll.h>
|
||||
#include <uORB/topics/vehicle_acceleration.h>
|
||||
..
|
||||
int sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
orb_sub_t sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
|
||||
/* one could wait for multiple topics with this technique, just using one here */
|
||||
px4_pollfd_struct_t fds[] = {
|
||||
@@ -469,7 +469,7 @@ int px4_simple_app_main(int argc, char *argv[])
|
||||
PX4_INFO("Hello Sky!");
|
||||
|
||||
/* subscribe to vehicle_acceleration topic */
|
||||
int sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
orb_sub_t sensor_sub_fd = orb_subscribe(ORB_ID(vehicle_acceleration));
|
||||
/* limit the update rate to 5 Hz */
|
||||
orb_set_interval(sensor_sub_fd, 200);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user