Python rospy.spin() Examples
The following are 30
code examples of rospy.spin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rospy
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: amazonpolly.py From tts-ros1 with Apache License 2.0 | 8 votes |
def start(self, node_name='polly_node', service_name='polly'): """The entry point of a ROS service node. Details of the service API can be found in Polly.srv. :param node_name: name of ROS node :param service_name: name of ROS service :return: it doesn't return """ rospy.init_node(node_name) service = rospy.Service(service_name, Polly, self._node_request_handler) rospy.loginfo('polly running: {}'.format(service.uri)) rospy.spin()
Example #2
Source File: robotiq_gripper_action_server.py From costar_plan with Apache License 2.0 | 8 votes |
def __init__(self): rospy.init_node('gripper_controller') self.msg = None self.r_pub = rospy.Publisher('gripper_controller/command', Float64, queue_size=10) """ self.t_pub = rospy.Publisher('arm_controller/command', JointTrajectory, queue_size=10) self.js_sub = rospy.Subscriber('joint_states', JointState, self._jointStateCb) """ # subscribe to command and then spin self.server = actionlib.SimpleActionServer('~gripper_action', GripperCommandAction, execute_cb=self.actionCb, auto_start=False) self.server.start() rospy.spin()
Example #3
Source File: wheel_scaler.py From differential-drive with GNU General Public License v3.0 | 7 votes |
def scaleWheel(): rospy.init_node("wheel_scaler") rospy.loginfo("wheel_scaler started") scale = rospy.get_param('distance_scale', 1) rospy.loginfo("wheel_scaler scale: %0.2f", scale) rospy.Subscriber("lwheel", Int16, lwheelCallback) rospy.Subscriber("rwheel", Int16, rwheelCallback) lscaled_pub = rospy.Publisher("lwheel_scaled", Int16, queue_size=10) rscaled_pub = rospy.Publisher("rwheel_scaled", Int16, queue_size=10) ### testing sleep CPU usage r = rospy.Rate(50) while not rospy.is_shutdown: r.sleep() rospy.spin()
Example #4
Source File: ros_svm.py From ROS-Programming-Building-Powerful-Robots with MIT License | 7 votes |
def listener(): global obj global pub rospy.loginfo("Starting prediction node") rospy.init_node('listener', anonymous = True) rospy.Subscriber("sensor_read", Int32, read_sensor_data) pub = rospy.Publisher('predict', Int32, queue_size=1) obj = Classify_Data() obj.read_file('pos_readings.csv') obj.train() rospy.spin()
Example #5
Source File: joy_driver_pid.py From crazyflieROS with GNU General Public License v2.0 | 6 votes |
def run(args=None): parser = OptionParser(description='Crazyflie ROS Driver') # parser.add_option('--uri', '-u', # dest='uri', # default='radio://0/4', # help='URI to connect to') (options, leftargs) = parser.parse_args(args=args) #Load some DB depending on options rospy.init_node('CrazyFlieJoystickDriver') joydriver = JoyController(options) #START NODE try: rospy.loginfo("Starting CrazyFlie joystick driver") rospy.spin() except KeyboardInterrupt: rospy.loginfo('...exiting due to keyboard interrupt')
Example #6
Source File: joy_driver.py From crazyflieROS with GNU General Public License v2.0 | 6 votes |
def run(args=None): parser = OptionParser(description='Crazyflie ROS Driver') # parser.add_option('--uri', '-u', # dest='uri', # default='radio://0/4', # help='URI to connect to') (options, leftargs) = parser.parse_args(args=args) #Load some DB depending on options rospy.init_node('CrazyFlieJoystickDriver') joydriver = JoyController(options) #START NODE try: rospy.loginfo("Starting CrazyFlie joystick driver") rospy.spin() except KeyboardInterrupt: rospy.loginfo('...exiting due to keyboard interrupt')
Example #7
Source File: lidarEvasion.py From Cherry-Autonomous-Racecar with MIT License | 6 votes |
def __init__(self): self.evadeSet = False self.controller = XBox360() self.bridge = CvBridge() self.throttle = 0 self.grid_img = None ##self.throttleLock = Lock() print "evasion" rospy.Subscriber("/lidargrid", Image, self.gridCB, queue_size=1) rospy.Subscriber("/cmd_vel", TwistStamped , self.twistCB , queue_size = 1) rospy.Subscriber("/joy", Joy, self.joyCB, queue_size=5) self.pub_img = rospy.Publisher("/steering_img", Image) self.pub_twist = rospy.Publisher("/lidar_twist", TwistStamped, queue_size=1) self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1) rospy.init_node ('lidar_cmd',anonymous=True) rospy.spin()
Example #8
Source File: dataRecorder.py From Cherry-Autonomous-Racecar with MIT License | 6 votes |
def __init__(self): print "dataRecorder" self.record = False self.twist = None self.twistLock = Lock() self.bridge = CvBridge() self.globaltime = None self.controller = XBox360() ##rospy.Subscriber("/camera/depth/points" , PointCloud2, self.ptcloudCB) rospy.Subscriber("/camera/depth/image_rect_raw_drop", Image, self.depthCB) rospy.Subscriber("/camera/rgb/image_rect_color_drop", Image, self.streamCB) #rospy.Subscriber("/camera/rgb/image_rect_mono_drop", Image, self.streamCB) ##for black and white images see run.launch and look at the drop fps nodes near the bottom rospy.Subscriber("/lidargrid", Image, self.lidargridCB) rospy.Subscriber("/cmd_vel", TwistStamped, self.cmd_velCB) rospy.Subscriber("/joy", Joy ,self.joyCB) self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1) rospy.init_node('dataRecorder',anonymous=True) rospy.spin()
Example #9
Source File: runModel.py From Cherry-Autonomous-Racecar with MIT License | 6 votes |
def __init__(self): rospy.loginfo("runner.__init__") # ---------------------------- self.sess = tf.InteractiveSession() self.model = cnn_cccccfffff() saver = tf.train.Saver() saver.restore(self.sess, "/home/ubuntu/catkin_ws/src/car/scripts/model.ckpt") rospy.loginfo("runner.__init__: model restored") # ---------------------------- self.bridge = CvBridge() self.netEnable = False self.controller = XBox360() rospy.Subscriber("/camera/rgb/image_rect_color", Image, self.runCB) rospy.Subscriber("/joy", Joy ,self.joyCB) self.pub_twist = rospy.Publisher("/neural_twist", TwistStamped, queue_size=1) self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1) rospy.init_node('neural_cmd',anonymous=True) rospy.spin()
Example #10
Source File: get_points.py From visual_foresight with MIT License | 6 votes |
def main_sawyer(): import intera_interface from visual_mpc.envs.robot_envs.sawyer.sawyer_impedance import SawyerImpedanceController controller = SawyerImpedanceController('sawyer', True, gripper_attached='none') # doesn't initial gripper object even if gripper is attached def print_eep(value): if not value: return xyz, quat = controller.get_xyz_quat() yaw, roll, pitch = [np.rad2deg(x) for x in controller.quat_2_euler(quat)] logging.getLogger('robot_logger').info("XYZ IS: {}, ROTATION IS: yaw={} roll={} pitch={}".format(xyz, yaw, roll, pitch)) navigator = intera_interface.Navigator() navigator.register_callback(print_eep, 'right_button_show') rospy.spin()
Example #11
Source File: cv_bridge_demo.py From Learning-Robotics-using-Python-Second-Edition with MIT License | 5 votes |
def main(args): try: cvBridgeDemo() rospy.spin() except KeyboardInterrupt: print "Shutting down vision node." cv.DestroyAllWindows()
Example #12
Source File: serial_adapter.py From RacingRobot with MIT License | 5 votes |
def listener(): rospy.init_node('serial_adapter', anonymous=True) # Declare the Subscriber to motors orders rospy.Subscriber("arduino/servo", Int16, servoCallback, queue_size=2) rospy.Subscriber("arduino/motor", Int8, motorCallback, queue_size=2) rospy.spin()
Example #13
Source File: hello_world_subscriber.py From Learning-Robotics-using-Python-Second-Edition with MIT License | 5 votes |
def listener(): # in ROS, nodes are unique named. If two nodes with the same # node are launched, the previous one is kicked off. The # anonymous=True flag means that rospy will choose a unique # name for our 'listener' node so that multiple listeners can # run simultaenously. rospy.init_node('hello_world_subscriber', anonymous=True) rospy.Subscriber("hello_pub", String, callback) # spin() simply keeps python from exiting until this node is stopped rospy.spin()
Example #14
Source File: detect_aruco.py From flock with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): # ArUco data -- we're using 6x6 ArUco images self._aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250) self._aruco_parameters = cv2.aruco.DetectorParameters_create() # Initialize ROS rospy.init_node('detect_aruco_node', anonymous=False) # ROS publishers self._image_pub = rospy.Publisher('image_marked', Image, queue_size=10) self._rviz_markers_pub = rospy.Publisher('rviz_markers', MarkerArray, queue_size=10) # ROS OpenCV bridge self._cv_bridge = CvBridge() # ROS transform managers self._tf_listener = tf.TransformListener() self._tf_broadcaster = tf.TransformBroadcaster() # Get base_link => camera_frame transform self._tf_listener.waitForTransform("base_link", "camera_frame", rospy.Time(), rospy.Duration(4)) self._Tcb = tf_to_matrix(self._tf_listener.lookupTransform("base_link", "camera_frame", rospy.Time())) # Now that we're initialized, set up subscriptions and spin rospy.Subscriber("image_raw", Image, self.image_callback) rospy.spin()
Example #15
Source File: test_dyncfg.py From tello_driver with Apache License 2.0 | 5 votes |
def main(): rospy.init_node('dyncfg_test') srv_dyncfg = Server(TelloConfig, cb_dyncfg) rospy.spin()
Example #16
Source File: tello_driver_node.py From tello_driver with Apache License 2.0 | 5 votes |
def main(): rospy.init_node('tello_node') robot = TelloNode() if robot.state != robot.STATE_QUIT: rospy.spin()
Example #17
Source File: tensorflow_in_ros_mnist.py From Tensorflow_in_ROS with Apache License 2.0 | 5 votes |
def main(self): rospy.spin()
Example #18
Source File: naoqi_node.py From naoqi_bridge with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __on_ros_shutdown(self): """ Callback function called whenever rospy.spin() stops """ rospy.loginfo('Stopping ' + self.__name) self.__stop_thread = True # wait for the thread to be done if self.is_alive(): self.join() rospy.loginfo(self.__name + ' stopped')
Example #19
Source File: read_ground_truth.py From DroneSimLab with MIT License | 5 votes |
def listener(): rospy.init_node('listener', anonymous=True) #rate=rospy.Rate(1) rospy.Subscriber('mavros/state', State, callback) rospy.Subscriber('mavros/hil_controls/hil_controls', HilControls, hil_callback) rospy.spin()
Example #20
Source File: joint_trajectory_action_server.py From intera_sdk with Apache License 2.0 | 5 votes |
def start_server(limb, rate, mode, valid_limbs): rospy.loginfo("Initializing node... ") rospy.init_node("sdk_{0}_joint_trajectory_action_server{1}".format( mode, "" if limb == 'all_limbs' else "_" + limb,)) rospy.loginfo("Initializing joint trajectory action server...") robot_name = intera_interface.RobotParams().get_robot_name().lower().capitalize() config_module = "intera_interface.cfg" if mode == 'velocity': config_name = ''.join([robot_name,"VelocityJointTrajectoryActionServerConfig"]) elif mode == 'position': config_name = ''.join([robot_name,"PositionJointTrajectoryActionServerConfig"]) else: config_name = ''.join([robot_name,"PositionFFJointTrajectoryActionServerConfig"]) cfg = importlib.import_module('.'.join([config_module,config_name])) dyn_cfg_srv = Server(cfg, lambda config, level: config) jtas = [] if limb == 'all_limbs': for current_limb in valid_limbs: jtas.append(JointTrajectoryActionServer(current_limb, dyn_cfg_srv, rate, mode)) else: jtas.append(JointTrajectoryActionServer(limb, dyn_cfg_srv, rate, mode)) def cleanup(): for j in jtas: j.clean_shutdown() rospy.on_shutdown(cleanup) rospy.loginfo("Joint Trajectory Action Server Running. Ctrl-c to quit") rospy.spin()
Example #21
Source File: cv_bridge_demo.py From Learning-Robotics-using-Python-Second-Edition with MIT License | 5 votes |
def main(args): try: cvBridgeDemo() rospy.spin() except KeyboardInterrupt: print "Shutting down vision node." cv.DestroyAllWindows()
Example #22
Source File: kinematics.py From pyrobot with MIT License | 5 votes |
def __init__(self): self.init_done = False rospy.init_node("pyrobot_kinematics") self.ik_srv = rospy.Service("pyrobot/ik", IkCommand, self.ik_server) self.fk_srv = rospy.Service("pyrobot/fk", FkCommand, self.fk_server) rospy.spin()
Example #23
Source File: ros_tensorflow_classify.py From ros_tensorflow with Apache License 2.0 | 5 votes |
def main(self): rospy.spin()
Example #24
Source File: ros_tensorflow_detect.py From ros_tensorflow with Apache License 2.0 | 5 votes |
def main(self): rospy.spin()
Example #25
Source File: ros_tensorflow_mnist.py From ros_tensorflow with Apache License 2.0 | 5 votes |
def main(self): rospy.spin()
Example #26
Source File: run_py_node.py From Robust-Lane-Detection-and-Tracking with MIT License | 5 votes |
def main(args): ic = image_converter() rospy.init_node('image_converter', anonymous=True) try: rospy.spin() except KeyboardInterrupt: print("Shutting down") cv2.destroyAllWindows()
Example #27
Source File: turtlesim_joy.py From ROS-Robotics-By-Example with MIT License | 5 votes |
def joy_listener(): # start node rospy.init_node("turtlesim_joy", anonymous=True) # subscribe to joystick messages on topic "joy" rospy.Subscriber("joy", Joy, tj_callback, queue_size=1) # keep node alive until stopped rospy.spin() # called when joy message is received
Example #28
Source File: SoundServer.py From Cherry-Autonomous-Racecar with MIT License | 5 votes |
def __init__(self): rospy.init_node('sound_server', anonymous=False) rospy.on_shutdown(self._shutdown) while (rospy.get_rostime() == 0.0): pass rospy.Subscriber("/sound_server/speech_synth", String, self.cb_speech_synth) rospy.Subscriber("/sound_server/play_sound_file", String, self.cb_play_sound_file) self.pub_status = rospy.Publisher("/sound_server/status", String) self.s = mirage_sound_out(festival_cache_path="/home/ubuntu/Music/mirage_engrams/festival_cache/", sound_effects_path="/home/ubuntu/Music/mirage_engrams/sound_effects/") rospy.sleep(2.0) # Startup time. rospy.loginfo("mirage_sound_out ready") rospy.spin()
Example #29
Source File: flieTracker.py From crazyflieROS with GNU General Public License v2.0 | 5 votes |
def __init__(self): rospy.init_node('flieLocaliser') self.maxDepth = 4.5 self.bg_thresh = 0.45 self.kernel = np.ones((3, 3), np.uint8) self.centerX = 319.5 self.centerY = 239.5 self.depthFocalLength = 525 # CV stuff self.bridge = CvBridge() # Subscribe #self.sub_rgb = rospy.Subscriber("/camera/rgb/image_raw", ImageMSG, self.new_rgb_data) self.sub_depth = rospy.Subscriber("/camera/depth_registered/image_raw", ImageMSG, self.new_depth_data) self.pub_depth = rospy.Publisher("/camera/detector", ImageMSG) self.sub_tf = tf.TransformListener() # Publish self.pub_tf = tf.TransformBroadcaster() # Members self.depth = None self.show = None self.counter = 30*4 self.acc = np.zeros((480,640,self.counter), dtype=np.float32) # Run ROS node rospy.loginfo('Node Started') try: rospy.spin() except KeyboardInterrupt: print "Shutting down" cv2.destroyAllWindows()
Example #30
Source File: listener.py From ros-bazel with MIT License | 5 votes |
def main(): rospy.init_node("listener", anonymous=True) sub = rospy.Subscriber("chatter", StampedHelloWithMessage, callback) rospy.spin()