rosbag to variable

asked 2015-11-03 06:21:56 -0600

Carollour gravatar image

updated 2015-11-03 07:49:14 -0600


I have saved a rosbag with the goal topic of an action:

messages:    1
compression: none [1/1 chunks]
types:       control_msgs/FollowJointTrajectoryActionGoal [cff5c1d533bf2f82dd0138d57f4304bb]
topics:      /robot_joint_trajectory_action_controller/follow_joint_trajectory/goal   1 msg     : control_msgs/FollowJointTrajectoryActionGoal

What I was trying to do was to copy this 1 message to a variable so I can call the service with this saved goal within my cpp node:

rosbag::Bag bag;"test.bag", rosbag::bagmode::Read);

std::vector<std::string> topics;

rosbag::View view(bag, rosbag::TopicQuery(topics));

foreach(rosbag::MessageInstance const m, view)
    control_msgs::FollowJointTrajectoryActionGoal::ConstPtr s = m.instantiate<control_msgs::FollowJointTrajectoryActionGoal>();
    if (s != NULL){



//wait for the action to return
bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0));

if (finished_before_timeout)
    actionlib::SimpleClientGoalState state = ac.getState();
    ROS_INFO("Action finished: %s",state.toString().c_str());
    ROS_INFO("Action did not finish before the time out.");

Of course i cannot do s=goal. How to do this?


edit retag flag offensive close merge delete