本文整理汇总了Python中std_srvs.srv.Empty方法的典型用法代码示例。如果您正苦于以下问题:Python srv.Empty方法的具体用法?Python srv.Empty怎么用?Python srv.Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_srvs.srv
的用法示例。
在下文中一共展示了srv.Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def __init__(self):
# ROS initialization:
rospy.init_node('pose_manager')
self.poseLibrary = dict()
self.readInPoses()
self.poseServer = actionlib.SimpleActionServer("body_pose", BodyPoseAction,
execute_cb=self.executeBodyPose,
auto_start=False)
self.trajectoryClient = actionlib.SimpleActionClient("joint_trajectory", JointTrajectoryAction)
if self.trajectoryClient.wait_for_server(rospy.Duration(3.0)):
try:
rospy.wait_for_service("stop_walk_srv", timeout=2.0)
self.stopWalkSrv = rospy.ServiceProxy("stop_walk_srv", Empty)
except:
rospy.logwarn("stop_walk_srv not available, pose_manager will not stop the walker before executing a trajectory. "
+"This is normal if there is no nao_walker running.")
self.stopWalkSrv = None
self.poseServer.start()
rospy.loginfo("pose_manager running, offering poses: %s", self.poseLibrary.keys());
else:
rospy.logfatal("Could not connect to required \"joint_trajectory\" action server, is the nao_controller node running?");
rospy.signal_shutdown("Required component missing");
示例2: stop
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def stop(self):
"""Stop the sensor.
"""
# Check that everything is running
if not self._running:
logging.warning('PhoXi not running. Aborting stop')
return False
# Stop the subscribers
self._color_im_sub.unregister()
self._depth_im_sub.unregister()
self._normal_map_sub.unregister()
# Disconnect from the camera
rospy.ServiceProxy('phoxi_camera/disconnect_camera', Empty)()
self._running = False
return True
示例3: on_button_reset_pressed
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def on_button_reset_pressed(self):
self._num_pattern_detections = 0
self._calibration_output = ""
self._update_required = True
self.button_start.setEnabled( False )
try:
rospy.wait_for_service('dvs_calibration/reset', 1)
try:
reset_service = rospy.ServiceProxy('dvs_calibration/reset', Empty)
resp = reset_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
print "service not available..."
pass
示例4: service_server
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def service_server():
rospy.init_node('service_server')
s = rospy.Service('call_me', Empty, handle_service)
print "Ready to serve."
rospy.spin()
示例5: execute
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def execute(self, inputs, outputs, gvm):
service = "/clear"
rospy.wait_for_service(service)
clear_turtle_area_service = rospy.ServiceProxy(service, Empty)
resp1 = clear_turtle_area_service()
self.logger.info("ROS external module: executed the {} service".format(service))
return 0
示例6: GetDetectObjectsService
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def GetDetectObjectsService(srv='/costar_perception/segmenter'):
'''
Get a service that will update object positions
Parameters:
----------
srv: service, defaults to the correct name for costar
'''
return GetService(srv, EmptySrv)
示例7: GetCloseGripperService
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def GetCloseGripperService():
return GetService("/costar/gripper/close", EmptySrv)
示例8: GetOpenGripperService
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def GetOpenGripperService():
return GetService("/costar/gripper/open", EmptySrv)
示例9: __init__
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def __init__(self):
self.index = 0
self.gazeboModels = None
self.img_np = None
self.pose = Odometry()
self.action = Twist()
rospy.Subscriber(overheadImageTopic, Image, self.imageCallback)
rospy.Subscriber(huskyCmdVelTopic, Twist, self.cmdVelCallback)
self.listener = tf.TransformListener()
self.writer = NpzDataset('husky_data')
self.trans = None
self.rot = None
self.roll, self.pitch, self.yaw = 0., 0., 0.
self.trans_threshold = 0.25
rospy.wait_for_service("/gazebo/pause_physics")
self.pause = rospy.ServiceProxy("/gazebo/pause_physics", EmptySrv)
self.unpause = rospy.ServiceProxy("/gazebo/unpause_physics", EmptySrv)
self.set_model_state = rospy.ServiceProxy("/gazebo/set_model_state",
SetModelState)
self.set_link_state = rospy.ServiceProxy("/gazebo/set_link_state",
SetLinkState)
self.get_link_state = rospy.ServiceProxy("/gazebo/get_link_state",
GetLinkState)
self.pose = None
示例10: call_service
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def call_service():
rospy.loginfo('waiting service')
rospy.wait_for_service('call_me')
try:
service = rospy.ServiceProxy('call_me', Empty)
response = service()
except rospy.ServiceException, e:
print "Service call failed: %s" % e
示例11: __init__
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def __init__(self, rate=20.0, id_mask='F1804'):
"""Initialize the weight publisher.
Parameters
----------
id_mask : str
A template for the first n digits of the device IDs for valid load cells.
"""
self._rate = rospy.Rate(rate)
self._pub = rospy.Publisher('~weights', Float32MultiArray, queue_size=10)
rospy.loginfo('Connecting serial')
self._serials = self._connect(id_mask)
if len(self._serials) == 0:
raise ValueError('Error -- No loadstar weight sensors connected to machine!')
# Tare the sensor
rospy.loginfo('Tareing')
self._tare()
# Flush the sensor's communications
self._flush()
# Set up Tare service
self._tare_service = rospy.Service('~tare', Empty, self._handle_tare)
# Main loop -- read and publish
while not rospy.is_shutdown():
weights = self._read_weights()
self._pub.publish(Float32MultiArray(data=weights))
self._rate.sleep()
示例12: frames
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def frames(self):
"""Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Returns
-------
:obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray`
The ColorImage, DepthImage, and IrImage of the current frame.
"""
# Run a software trigger
times = []
rospy.ServiceProxy('phoxi_camera/start_acquisition', Empty)()
rospy.ServiceProxy('phoxi_camera/trigger_image', TriggerImage)()
self._cur_color_im = None
self._cur_depth_im = None
self._cur_normal_map = None
rospy.ServiceProxy('phoxi_camera/get_frame', GetFrame)(-1)
max_time = 5.0
time_waiting = 0.0
while self._cur_color_im is None or self._cur_depth_im is None or self._cur_normal_map is None:
time.sleep(0.05)
time_waiting += 0.05
if time_waiting > max_time:
raise SensorUnresponsiveException('PhoXi sensor seems to be non-responsive')
return self._cur_color_im, self._cur_depth_im, None
示例13: tare
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def tare(self):
"""Zero out (tare) the sensor.
"""
if not self._running:
raise ValueError('Weight sensor is not running!')
rospy.ServiceProxy('weight_sensor/tare', Empty)()
示例14: on_button_start_calibration_pressed
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def on_button_start_calibration_pressed(self):
self.button_start.setEnabled( False )
try:
rospy.wait_for_service('dvs_calibration/start', 1)
try:
start_calibration_service = rospy.ServiceProxy('dvs_calibration/start', Empty)
resp = start_calibration_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
print "service not available..."
pass
示例15: on_button_save_calibration_pressed
# 需要导入模块: from std_srvs import srv [as 别名]
# 或者: from std_srvs.srv import Empty [as 别名]
def on_button_save_calibration_pressed(self):
try:
rospy.wait_for_service('dvs_calibration/save', 1)
try:
save_calibration_service = rospy.ServiceProxy('dvs_calibration/save', Empty)
resp = save_calibration_service()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
except:
print "service not available..."
pass