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

how to set the initial pose of turtlesim

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

chao gravatar image

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

ngrennan gravatar image

Hi, how can i set the initial pose of the /turtle2 in tf_listener from this tutorial:

i tried this:

  ros::ServiceClient add_turtle =
  turtlesim::Spawn srv;
  srv.Request.x = 5; //added
  srv.Request.y = 5; //added;

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

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

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


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

Seen: 3,795 times

Last updated: Nov 21 '14