Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic subscriptions #16

Merged
merged 5 commits into from
Dec 18, 2023
Merged

Generic subscriptions #16

merged 5 commits into from
Dec 18, 2023

Conversation

DanMesh
Copy link
Contributor

@DanMesh DanMesh commented Dec 14, 2023

Allows adding subscriptions to arbitrary ROS topics.
Users can register (multiple) callbacks or simply poll the last-received message.

Example usage

px4_ros2::Subscription<px4_msgs::msg::VehicleLocalPosition> ros_sub(context, "/fmu/out/vehicle_local_position");

// Create callback
ros_sub.onUpdate([](px4_msgs::msg::VehicleLocalPosition msg) {
    std::cout << "Local pos from callback: " << msg.x << " " << msg.y << " " << msg.z << std::endl;
});

// Poll latest message
px4_msgs::msg::VehicleLocalPosition msg = ros_sub.last();
std::cout << "Local pos latest: " << msg.x << " " << msg.y << " " << msg.z << std::endl;

@DanMesh DanMesh self-assigned this Dec 14, 2023
@DanMesh DanMesh marked this pull request as ready for review December 14, 2023 15:56
@DanMesh DanMesh requested a review from bkueng December 14, 2023 15:56
@DanMesh DanMesh requested a review from bkueng December 15, 2023 10:35
@DanMesh DanMesh requested a review from bkueng December 15, 2023 16:57
Copy link
Collaborator

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@bkueng bkueng merged commit 669848e into main Dec 18, 2023
@bkueng bkueng deleted the subscriptions branch December 18, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants