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

subscribing to data from gazebo plugin

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

hmmm gravatar image

updated 2012-01-12 01:58:58 -0600

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

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

DimitriProsser gravatar image

The header file that you're looking for is:

#include <nav_msgs/Odometry.h>
edit flag offensive delete link more

Question Tools

Stats

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

Seen: 1,158 times

Last updated: Jan 12 '12