The main difference lies in the implementation of the bottom layer, and the application program interface changes relatively little. It also passed the uORB unit test of PX4 Autopilot.
- Unified publication and subscription type:
orb_publication_t*
andorb_subscription_t*
- Pass pointers when unpublishing and unsubscribing to avoid wild pointers(Reference from zmq)
- Use
bool
type (include in<stdbool.h>
) to indicate whether the operation is successful - Add independent
orb_poll
function, instead ofpx4_poll
in PX4 Autopilot - Configure the topic's queue size in the topic's metadata, not at the time of publishing, which is good for a single topic with multiple publishers.
PX4 uORB | Current uORB |
---|---|
orb_advert_t orb_advertise_queue(const struct orb_metadata *meta, const void *data~~, unsigned int queue_size~~) | orb_publication_t *orb_create_publication(const struct orb_metadata *meta) |
orb_advert_t orb_advertise_multi_queue(const struct orb_metadata *meta, |
orb_publication_t *orb_create_publication_multi(const struct orb_metadata *meta, unsigned int *instance) |
int orb_publish( |
bool orb_publish(orb_publication_t *handle, const void *data) |
int orb_unadvertise(orb_advert_t handle) | bool orb_destroy_publication(orb_publication_t **handle_ptr) |
int orb_subscribe(const struct orb_metadata *meta) | **orb_subscription_t ***orb_create_subscription(const struct orb_metadata *meta) |
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance) | **orb_subscription_t ***orb_create_subscription_multi(const struct orb_metadata *meta, unsigned instance) |
int orb_unsubscribe(int handle) | bool orb_destroy_subscription(orb_subscription_t handle_ptr**) |
int orb_copy( |
bool orb_copy(*orb_subscription_t handle, void *buffer) |
int orb_check(int handle |
bool orb_check_update(*orb_subscription_t handle) |
int px4_poll(px4_pollfd_struct_t *fds, unsigned int nfds, int timeout) | int orb_poll(struct orb_pollfd *fds, unsigned int nfds, int timeout_ms) |
- Delete the
o_id
(ORB_ID enum
) field inorb_metadata
. This field has no meaning and is very redundant. It is newly added in PX4-v1.11. - In C++,
orb_metadata
can be obtained directly through the orb message type, which can simplify the constructors ofPublicationData
andSubscriptionData
, and there is no need to pass in parameters such asORB_ID(msg_name)
to simplify the code and avoid errors.