38 import roslib; roslib.load_manifest(
'rcprg_ros_utils')
48 if __name__ ==
"__main__":
49 rospy.init_node(
'create_state_snapshot', anonymous=
False)
54 print 'Waiting for ROS services...' 55 rospy.wait_for_service(
'/gazebo/get_world_properties')
56 rospy.wait_for_service(
'/gazebo/get_model_properties')
57 rospy.wait_for_service(
'/gazebo/get_joint_properties')
58 rospy.wait_for_service(
'/gazebo/pause_physics')
59 rospy.wait_for_service(
'/gazebo/unpause_physics')
61 get_world_properties = rospy.ServiceProxy(
'/gazebo/get_world_properties', GetWorldProperties)
62 get_model_properties = rospy.ServiceProxy(
'/gazebo/get_model_properties', GetModelProperties)
63 get_joint_properties = rospy.ServiceProxy(
'/gazebo/get_joint_properties', GetJointProperties)
64 pause_physics = rospy.ServiceProxy(
'/gazebo/pause_physics', std_srvs.srv.Empty)
65 unpause_physics = rospy.ServiceProxy(
'/gazebo/unpause_physics', std_srvs.srv.Empty)
66 except rospy.ServiceException, e:
67 print "Service call failed: %s"%e
75 for model_name
in world_prop.model_names:
76 print 'model_name:', model_name
78 print 'joint_names:', model_prop.joint_names
79 for joint_name
in model_prop.joint_names:
81 if math.isnan(joint_prop.position[0]):
83 if joint_prop.type == GetJointPropertiesResponse.REVOLUTE
or \
84 joint_prop.type == GetJointPropertiesResponse.CONTINUOUS
or \
85 joint_prop.type == GetJointPropertiesResponse.PRISMATIC:
86 print ' ' + joint_name +
' ' + str(joint_prop.position) +
'type:' + str(joint_prop.type)
87 file_lines.append( model_name +
' ' + joint_name +
' ' + str(joint_prop.position[0]) )
89 print ' ' + joint_name +
' of type ' + str(joint_prop.type) +
' is not supported' 90 print 'You can now save the Gazebo world using Gazebo client (File->Save World As).' 91 with open(
'state_snapshot.txt',
'w')
as f:
92 for line
in file_lines: