2 #include "gazebo_msgs/SetModelState.h" 3 #include "gazebo_msgs/GetModelState.h" 18 float x0 = x, y0 = y, z0 = z;
20 float ox0 = 0.0, oy0 = 0.0, oz0 = 1.0;
21 geometry_msgs::Pose start_pose0;
22 start_pose0.position.x = x0;
23 start_pose0.position.y = y0;
24 start_pose0.position.z = z0;
25 start_pose0.orientation.x = ox0*sin(theta0/2);
26 start_pose0.orientation.y = oy0*sin(theta0/2);
27 start_pose0.orientation.z = oz0*sin(theta0/2);
28 start_pose0.orientation.w = cos(theta0/2);
29 geometry_msgs::Twist start_twist0;
30 start_twist0.linear.x = 0.0;
31 start_twist0.linear.y = 0.0;
32 start_twist0.linear.z = 0.0;
33 start_twist0.angular.x = 0.0;
34 start_twist0.angular.y = 0.0;
35 start_twist0.angular.z = 0.0;
36 gazebo_msgs::ModelState modelstate0;
38 sprintf(name,
"robot_%d", rbtID);
39 modelstate0.model_name = (std::string)name;
40 modelstate0.reference_frame = (std::string)
"world";
41 modelstate0.pose = start_pose0;
42 modelstate0.twist = start_twist0;
43 gazebo_msgs::SetModelState setmodelstate0;
44 setmodelstate0.request.model_state = modelstate0;
46 if (client.
call(setmodelstate0))
58 int main(
int argc,
char **argv)
60 ros::init(argc, argv,
"ModelState_client");
256 if(!poseSetSuccess) printf(
"set pose failed\n");
259 if(!poseSetSuccess) printf(
"set pose failed\n");
262 if(!poseSetSuccess) printf(
"set pose failed\n");
265 if(!poseSetSuccess) printf(
"set pose failed\n");
268 if(!poseSetSuccess) printf(
"set pose failed\n");
271 if(!poseSetSuccess) printf(
"set pose failed\n");
274 if(!poseSetSuccess) printf(
"set pose failed\n");
277 if(!poseSetSuccess) printf(
"set pose failed\n");
280 if(!poseSetSuccess) printf(
"set pose failed\n");
283 if(!poseSetSuccess) printf(
"set pose failed\n");
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
const float camera_height
bool setStartPose(ros::ServiceClient client, int rbtID, float x, float y, float z=camera_height)