ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Under fuerte, I ha the same problem, I diactivate the gravity from e GUI and used the follwing code:
ros::ServiceClient client = node_handle_.serviceClient<gazebo_msgs::SetModelState>("/gazebo/set_model_state");
geometry_msgs::Pose start_pose;
start_pose.position.x = currPosel.x+0.01;
start_pose.position.y = currPosel.x+0.01;
start_pose.position.z = 1.0;
start_pose.orientation.x = 0.0;
start_pose.orientation.y = 0.0;
start_pose.orientation.z = 0.0;
start_pose.orientation.w = 0.0;
geometry_msgs::Twist start_twist;
start_twist.linear.x = 1.1;
start_twist.linear.y = 0;
start_twist.linear.z = 0;
start_twist.angular.x = 0.0;
start_twist.angular.y = 0.0;
start_twist.angular.z = 0.0;
//---------------------------------------------------------------------
gazebo_msgs::SetModelState setmodelstate;
gazebo_msgs::ModelState modelstate;
modelstate.model_name = "my_object";
modelstate.reference_frame = "world";
modelstate.twist = start_twist;
modelstate.pose = start_pose;
setmodelstate.request.model_state = modelstate;
if (client.call(setmodelstate))
{
ROS_INFO("BRILLIANT!!!");
ROS_INFO("%f, %f",modelstate.pose.position.x,modelstate.pose.position.y);
}
else
{
ROS_ERROR("Failed to call service ");
return 1;
}
return 0;