0
$\begingroup$

Rosanswers logo

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.


Originally posted by ozo on ROS Answers with karma: 5 on 2015-04-24

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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;   
}

Originally posted by bvbdort with karma: 3034 on 2015-04-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ozo on 2015-04-24:
Thank you for your answer but my problem is after subscribing how to make this for example double x=linear_acceleration.x;

Comment by bvbdort on 2015-04-24:
check the update

Comment by ozo on 2015-04-24:
Thank you very much. It worked

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.