Ask Your Question
0

Extract data from bag as variables in CPP

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

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 -0600

bvbdort gravatar image

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

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 imageozo ( 2015-04-24 06:39:22 -0600 )edit

check the update

bvbdort gravatar imagebvbdort ( 2015-04-24 08:27:10 -0600 )edit

Thank you very much. It worked

ozo gravatar imageozo ( 2015-04-24 10:23:46 -0600 )edit

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: 2015-04-24 04:14:28 -0600

Seen: 111 times

Last updated: Apr 24 '15