Ask Your Question
0

How do I write a C++ code to record variable location of robot in rosbag file?

asked 2016-06-21 02:04:26 -0600

Pikachu gravatar image

updated 2016-06-21 02:10:48 -0600

I have written a code to record in rosbag file. But if the rosbag file starts, then the robot does not move because of sequential way of code. Here is that part of code :

i=system("rosbag record -a");
while(ros::ok())
{   
    //Declares the message to be sent
    geometry_msgs::Twist msg;
    msg.linear.x=3;
    msg.angular.z=-0.3;
    //Publish the message
    pub.publish(msg);
    //Delays until it is time to send another message   
    rate.sleep();   
}

I need to record in rosbag file while simultaneously moving the robot, then after sometime close the file. How to do that?

edit retag flag offensive close merge delete

Comments

maybe checking out this discussion helps.

mgruhler gravatar imagemgruhler ( 2016-06-21 02:13:38 -0600 )edit

I already checked it. It only provides the way to start rosbag file in a code, which I did. I need to simultaneously move the robot and later close the file through code.

Pikachu gravatar imagePikachu ( 2016-06-21 03:21:55 -0600 )edit

You can use a service to close the file when you want.

F.Brosseau gravatar imageF.Brosseau ( 2016-06-21 04:05:35 -0600 )edit

Can you explain me on how to use a service? I am unaware of that. Are you talking about something of service-client kind?

Pikachu gravatar imagePikachu ( 2016-06-21 06:49:16 -0600 )edit

Yes it's another way to communicate with ROS nodes. Services allow you to communicate with nodes at a given time.

You can look to the ros wiki for more information : http://wiki.ros.org/ROS/Tutorials/WritingServiceClient(c%2B%2B))

F.Brosseau gravatar imageF.Brosseau ( 2016-06-21 07:49:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-28 23:27:55 -0600

shashank gravatar image

updated 2016-06-28 23:28:52 -0600

I think you can create a bag file using rosbag api and write your topics in it .link text

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-06-21 02:04:26 -0600

Seen: 374 times

Last updated: Jun 28 '16