Ask Your Question
0

subscribing to data from gazebo plugin

asked 2012-01-11 10:27:57 -0500

hmmm gravatar image

updated 2012-01-12 01:58:58 -0500

hello,i would like to subscribe the hight information and the orientation information of the plugin,that is included within the urdf-file. here the included part :

  <controller:gazebo_ros_p3d name="quadro_groundtruth_sim" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100.0</updateRate>
    <bodyName>imu_link</bodyName>
    <topicName>ground_truth_pose</topicName>
    <gaussianNoise>0.0</gaussianNoise>
    <frameName>map</frameName>
    <interface:position name="my_box_p3d_position_iface" />
  </controller:gazebo_ros_p3d>

how can i subscribe this hight information and the orientation information within a node? i tried following.But i don't know how to proceed.

#include "ros/ros.h"
#include "std_msgs/String.h"
#include "gazebo_ros_p3d.h"      // is that the header i have to include???

void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO("I heard: [%s]", msg->data.c_str());
}

int main(int argc, char **argv)
{

  ros::init(argc, argv, "listener");      
  ros::NodeHandle n;
  ros::Subscriber sub = n.subscribe("ground_truth_pose", 1000, chatterCallback);

  ros::spin();

  return 0;
}

But where is my mistake? thanks,regards

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-01-11 18:08:58 -0500

I strongly suggest you take a in-depth look at the beginner tutorials, especially Understanding ROS Topics and Writing a Simple Publisher and Subscriber (C++) ones.

I can spot at least two mistakes:

  • The subscriber callback has to based on the correct type (not std_msgs:String but nav_msgs/Odometry)
  • You have to include the corresponding message header, not gazebo_ros_p3d
edit flag offensive delete link more
0

answered 2012-01-12 00:49:06 -0500

DimitriProsser gravatar image

The header file that you're looking for is:

#include <nav_msgs/Odometry.h>
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

Stats

Asked: 2012-01-11 10:27:57 -0500

Seen: 985 times

Last updated: Jan 12 '12