ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Extract data from bag as variables in CPP

asked 2015-04-24 04:14:28 -0500

ozo gravatar image

I have a imu bag file and I want to take linear acceleration values xyz in cpp in variables so I could integrate them twice to get position but I am new at ROS and I do not know how ? I hope my question is clear. Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-24 05:43:38 -0500

bvbdort gravatar image

updated 2015-04-24 08:25:58 -0500

play bag file using rosbag

robag play xxxxx.bag --clock

it will publish all the topics in bags file.

Write subcriber in your code to get values.

check this for more info


Edit

ros::Subscriber sub = nh.subscribe("imu", 1000, &imuCallback, this);    

void Callback(const sensor_msgs::Imu::ConstPtr& msg)
{

    double lax = msg->linear_acceleration.x;
    double lay = msg->linear_acceleration.y;
    double laz= msg->linear_acceleration.z;   
}
edit flag offensive delete link more

Comments

Thank you for your answer but my problem is after subscribing how to make this for example double x=linear_acceleration.x;

ozo gravatar image ozo  ( 2015-04-24 06:39:22 -0500 )edit

check the update

bvbdort gravatar image bvbdort  ( 2015-04-24 08:27:10 -0500 )edit

Thank you very much. It worked

ozo gravatar image ozo  ( 2015-04-24 10:23:46 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-04-24 04:14:28 -0500

Seen: 305 times

Last updated: Apr 24 '15