Initialising /odom

asked 2017-04-29 18:36:10 -0600

rsmitha gravatar image

updated 2017-04-29 19:33:14 -0600

Hi,

I read this discussion on answers.ros: http://answers.ros.org/question/23522...

What I understand is that, "/odom" takes its initial orientation from the "IMU". So if I publish a certain orientation in quarternion to "sensor_msgs::Imu" I should be able initialise the "odom" frame to start in that direction.

I did the following:

void Initialise(sensor_msgs::Imu &msg_value)
{
msg_value.header.stamp = ros::Time::now();
msg_value.header.frame_id = "/odom";
msg_value.angular_velocity.x = 0.0;
msg_value.angular_velocity.y = 0.0;
msg_value.angular_velocity.z = 0.0;
msg_value.linear_acceleration.x = 0.0;
msg_value.linear_acceleration.y = 0.0;
msg_value.linear_acceleration.z = 0.0;
msg_value.orientation.x = 0.0;
msg_value.orientation.y = 1.0;
msg_value.orientation.z = 0.0;
msg_value.orientation.w = 0.0;
}
int main(int argc, char** argv)
{
    blah....
    geometry_msgs::Twist msg;
    geometry_msgs::PoseWithCovarianceStamped msg_setpose;
    nav_msgs::Odometry nav_msg;
    sensor_msgs::JointState jt_msg;
    gazebo_msgs::SetModelState set_model_state;
    gazebo_msgs::ModelState model_state;
    sensor_msgs::Imu msg_imu;
    ros::NodeHandle nh;
    ros::init(argc, argv, "random_commands");
    ros::Publisher pub_imu=nh.advertise<sensor_msgs::Imu>("imu/data", 100);
    Initialise(msg_imu);
    pub_imu.publish(msg_imu);
    ros::Rate rate(10); 
    srand(time(0)); 
    while(ros::ok()) {
    //give speed
    //check distance
    ....blah..
    rate.sleep();
   }
   ros::spin();
   return 0;
}

All headers have been included and the code compiles. I subscribe to "nav_msgs::Odometry" which I think uses, "geometry_msgs::Pose", to get the odometry data with respect to position and orientation. Speed is being fed in the x direction through the "cmd_vel" topic.

What I expected to see: I expected the odom frame to be initialised as per the IMU data. So I expected the robot to turn by 90degrees in the odom frame and start moving as speed came in. I expected to see the odometry data to show increase in the 'y' direction. But this does not seem to be the case.

The ekf_localisation is part of the jackal-ros pakage I think. What am I doing wrong? Is my understanding wrong?

Please help.

Regards, rsmitha.

edit retag flag offensive close merge delete

Comments

Did you fix that? I am trying to get Odom from PoseWithCovarianceStamped...

Andreluizfc gravatar image Andreluizfc  ( 2018-02-12 16:32:02 -0600 )edit

Hi @Andreluizfc, I was trying to get the simulated jackal to start a particular orientation. However, I did not make the changes which were part of the https://answers.ros.org/question/2352... . Please see next comment.

rsmitha gravatar image rsmitha  ( 2018-02-12 17:22:33 -0600 )edit

I was not using the fused data from ekf_localisation/robot_localisation packages. The idea was for me to be just able to orient the robot the way I wanted. Are you trying that? Please see next comment.

rsmitha gravatar image rsmitha  ( 2018-02-12 17:23:38 -0600 )edit
1

If you just trying to use PoseWithCovarianceStamped, you should be able to subscribe to it and get your odom data. That works.

rsmitha gravatar image rsmitha  ( 2018-02-12 17:25:22 -0600 )edit

Ohhh. Seems nice! Thanks for the tip!

Andreluizfc gravatar image Andreluizfc  ( 2018-02-13 14:35:00 -0600 )edit