Last active
February 14, 2021 13:44
-
-
Save wjwwood/b67d07a171f89faa8939 to your computer and use it in GitHub Desktop.
Example C++ Subscription, use `c++ -I/opt/ros/hydro/include -L/opt/ros/hydro/lib -lroscpp -lroscpp_serialization -lrosconsole my_node.cpp -o my_node`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include "ros/ros.h" | |
| #include "geometry_msgs/PoseStamped.h" | |
| std::vector<geometry_msgs::PoseStamped::ConstPtr> poses; | |
| void handle_poses(const geometry_msgs::PoseStamped::ConstPtr& msg) | |
| { | |
| ROS_INFO_STREAM("Received pose: " << msg); | |
| // Use the msg object here to access the pose elements, | |
| // like msg->pose.pose.position.x | |
| poses.push_back(msg); | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| ros::init(argc, argv, "my_node"); | |
| ros::NodeHandle n; | |
| ros::Subscriber sub = n.subscribe("/monocular_pose_estimator/estimated_pose", | |
| 1000, handle_poses); | |
| ros::spin(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment