Closed DanMesh closed 11 months ago
Allows adding subscriptions to arbitrary ROS topics. Users can register (multiple) callbacks or simply poll the last-received message.
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;
Allows adding subscriptions to arbitrary ROS topics. Users can register (multiple) callbacks or simply poll the last-received message.
Example usage