我们从Python开源项目中,提取了以下48个代码示例,用于说明如何使用rospy.ROSInterruptException()。
def cmmnd_FingerPosition(self, finger_value): commands.getoutput('rosrun kinova_demo fingers_action_client.py j2n6a300 percent -- {0} {1} {2}'.format(finger_value[0],finger_value[1],finger_value[2])) # fingers_action_client.getCurrentFingerPosition('j2n6a300_') # # finger_turn, finger_meter, finger_percent = fingers_action_client.unitParser('percent', finger_value, '-r') # finger_number = 3 # finger_maxDist = 18.9/2/1000 # max distance for one finger in meter # finger_maxTurn = 6800 # max thread turn for one finger # # try: # if finger_number == 0: # print('Finger number is 0, check with "-h" to see how to use this node.') # positions = [] # Get rid of static analysis warning that doesn't see the exit() # exit() # else: # positions_temp1 = [max(0.0, n) for n in finger_turn] # positions_temp2 = [min(n, finger_maxTurn) for n in positions_temp1] # positions = [float(n) for n in positions_temp2] # # print('Sending finger position ...') # result = fingers_action_client.gripper_client(positions) # print('Finger position sent!') # # except rospy.ROSInterruptException: # print('program interrupted before completion')
def run(self): rate = rospy.Rate(5.0) while not rospy.is_shutdown(): try: #listener("Game_MAKI") if self.key == True: print 'last_msg', self.last_msg print 'current_msg', self.current_msg print 'task', self.task, self.colorTask #dm = RobotManager() ###working area April 6th for elem in self.task: self.dm.say(elem, wait = True) self.task = [] self.last_msg = self.current_msg self.lastColor = self.currentColor self.key = False ### except rospy.ROSInterruptException: pass rate.sleep()
def start_return_calculator(time_scale, GVF, num_features, features_to_use, behavior_policy, target_policy): try: return_calculator = ReturnCalculator(time_scale, GVF, num_features, features_to_use, behavior_policy, target_policy) return_calculator.run() except rospy.ROSInterruptException as detail: rospy.loginfo("Handling: {}".format(detail))
def start_learning_foreground(time_scale, GVFs, topics, policy, stats, control_gvf=None, cumulant_counter=None, reset_episode=None, custom_stats=None): """Function to call with multiprocessing or multithreading. """ try: foreground = LearningForeground(time_scale, GVFs, topics, policy, stats, control_gvf, cumulant_counter, reset_episode) foreground.run() except rospy.ROSInterruptException as detail: rospy.loginfo("Handling: {}".format(detail))
def main(): import signal rospy.init_node('uwb_multi_range_node') u = UWBMultiRange() def sigint_handler(sig, _): if sig == signal.SIGINT: u.stop() signal.signal(signal.SIGINT, sigint_handler) try: u.exec_() except (rospy.ROSInterruptException, select.error): rospy.logwarn("Interrupted... Stopping.")
def main(): import signal rospy.init_node('uwb_tracker_node') u = UWBTracker() def sigint_handler(sig, _): if sig == signal.SIGINT: u.stop() signal.signal(signal.SIGINT, sigint_handler) try: u.exec_() except (rospy.ROSInterruptException, select.error): rospy.logwarn("Interrupted... Stopping.")
def cmmnd_CartesianPosition(self, pose_value, relative): pose_action_client.getcurrentCartesianCommand('j2n6s300_') pose_mq, pose_mdeg, pose_mrad = pose_action_client.unitParser('mq', pose_value, relative) poses = [float(n) for n in pose_mq] orientation_XYZ = pose_action_client.Quaternion2EulerXYZ(poses[3:]) try: poses = [float(n) for n in pose_mq] result = pose_action_client.cartesian_pose_client(poses[:3], poses[3:]) except rospy.ROSInterruptException: print ("program interrupted before completion")
def cmmnd_JointAngles(self,joints_cmd, relative): joints_action_client.getcurrentJointCommand('j2n6s300_') joint_degree, joint_radian = joints_action_client.unitParser('degree', joints_cmd, relative) try: positions = [float(n) for n in joint_degree] result = joints_action_client.joint_angle_client(positions) except rospy.ROSInterruptException: print('program interrupted before completion')
def cmmnd_CartesianPosition(self, pose_value, relative): ''' Commands the arm in cartesian position mode. Server client interface from kinova api. ''' pose_action_client.getcurrentCartesianCommand('j2n6s300_') pose_mq, pose_mdeg, pose_mrad = pose_action_client.unitParser('mq', pose_value, relative) poses = [float(n) for n in pose_mq] orientation_XYZ = pose_action_client.Quaternion2EulerXYZ(poses[3:]) try: poses = [float(n) for n in pose_mq] result = pose_action_client.cartesian_pose_client(poses[:3], poses[3:]) except rospy.ROSInterruptException: print ("program interrupted before completion")
def cmmnd_JointAngles(self,joints_cmd, relative): ''' Commands the arm in joint position mode. Server client interface from kinova api. ''' joints_action_client.getcurrentJointCommand('j2n6s300_') joint_degree, joint_radian = joints_action_client.unitParser('degree', joints_cmd, relative) try: positions = [float(n) for n in joint_degree] result = joints_action_client.joint_angle_client(positions) except rospy.ROSInterruptException: print('program interrupted before completion')
def cmmnd_CartesianPosition(self, pose_value, relative): pose_action_client.getcurrentCartesianCommand('j2n6a300_') pose_mq, pose_mdeg, pose_mrad = pose_action_client.unitParser('mq', pose_value, relative) poses = [float(n) for n in pose_mq] orientation_XYZ = pose_action_client.Quaternion2EulerXYZ(poses[3:]) try: poses = [float(n) for n in pose_mq] result = pose_action_client.cartesian_pose_client(poses[:3], poses[3:]) except rospy.ROSInterruptException: print ("program interrupted before completion")
def cmmnd_JointAngles(self,joints_cmd, relative): joints_action_client.getcurrentJointCommand('j2n6a300_') joint_degree, joint_radian = joints_action_client.unitParser('degree', joints_cmd, relative) try: # print("dafuq") positions = [float(n) for n in joint_degree] result = joints_action_client.joint_angle_client(positions) except rospy.ROSInterruptException: print('program interrupted before completion')
def main(): rospy.init_node('mobile_robot_tracker', log_level=rospy.INFO) rospy.loginfo("Starting tracking node...") try: tracker = MobileTracker() except rospy.ROSInterruptException: pass rospy.spin()
def main(): rospy.init_node('system_calibrator', log_level=rospy.INFO) rospy.loginfo("Calibration node started") rospy.loginfo("Press 'c' to begin calibration") try: calibrator = SystemCalibrator() except rospy.ROSInterruptException: pass rospy.spin()
def print_time(threadName, delay): global f global last_time rate = rospy.Rate(10) # 10hz while not rospy.is_shutdown(): try: if rospy.get_time() - last_time >= 60.0: last_time = rospy.get_time() f.close() f = open('log_file' + str(datetime.datetime.now()) + '.txt','w') except rospy.ROSInterruptException: pass rate.sleep()
def __init__(self): # create subscribers, timers, clients, etc. try: rospy.wait_for_service("/check_state_validity", timeout=5) except ROSException: rospy.logwarn("[check_collisions_node] Done waiting for /check_state_validity service... service not found") rospy.logwarn("shutting down...") rospy.signal_shutdown("service unavailable") except ROSInterruptException: pass self.coll_client = rospy.ServiceProxy("check_state_validity", GetStateValidity) self.js_sub = rospy.Subscriber("joint_state_check", numpy_msg(Float32MultiArray), self.js_cb) self.js_pub = rospy.Publisher("collision_check", Int16, queue_size = 10) return
def main(): rospy.init_node('check_collisions_node', log_level=rospy.INFO) rospy.loginfo("Starting up collision checking demo node") try: coll_checker = CheckCollisionState() except rospy.ROSInterruptException: pass rospy.spin()
def start_action_manager(): """Runs the action manager""" try: action_manager = ActionManager() action_manager.run() except rospy.ROSInterruptException as detail: rospy.loginfo("Handling: {}".format(detail))