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

how to set the initial pose of turtlesim

asked 2014-01-09 18:56:46 -0600

chao gravatar image

updated 2014-01-28 17:07:32 -0600

ngrennan gravatar image

Hi, how can i set the initial pose of the /turtle2 in tf_listener from this tutorial: http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20listener%20%28C%2B%2B%29

i tried this:

 ros::service::waitForService("spawn");
  ros::ServiceClient add_turtle =
       node.serviceClient<turtlesim::Spawn>("spawn");
  turtlesim::Spawn srv;
  srv.Request.x = 5; //added
  srv.Request.y = 5; //added
  add_turtle.call(srv);

but it shows up error when i try to compile

/home/chao/abc/src/learning_tf/src/turtle_tf_listener.cpp:15:7: error: invalid use of ‘turtlesim::Spawn::Request’
/home/chao/abc/src/learning_tf/src/turtle_tf_listener.cpp:16:7: error: invalid use of ‘turtlesim::Spawn::Request’
make[2]: *** [learning_tf/CMakeFiles/turtle_tf_listener.dir/src/turtle_tf_listener.cpp.o] Error 1

how can i set the initial pose for the /turtle1 as well? i suppose that the following (from tf_broadcaster tutorial) has nothing to do with the initial pose, just to set the transform with respect to the /world?

void poseCallback(const turtlesim::PoseConstPtr& msg){
  static tf::TransformBroadcaster br;
  tf::Transform transform;
  transform.setOrigin( tf::Vector3(msg->x, msg->y, 0.0) );
  transform.setRotation( tf::Quaternion(0, 0, msg->theta) );
  br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world", turtle_name));
}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-11-21 11:52:38 -0600

Shokoofeh gravatar image

Try this:

  turtlesim::Spawn srv;
  srv.request.x = 4;
  srv.request.y = 1;
  srv.request.theta = 0;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-01-09 18:56:46 -0600

Seen: 3,871 times

Last updated: Nov 21 '14