Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón

Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón

Author:Bernardo Ronquillo Japón [Bernardo Ronquillo Japón]
Language: eng
Format: epub
Tags: COM051360 - COMPUTERS / Programming Languages / Python, COM067000 - COMPUTERS / Hardware / General, COM059000 - COMPUTERS / Computer Engineering
Publisher: Packt Publishing
Published: 2020-02-26T06:15:42+00:00


Creating and running publisher and subscriber nodes

If you have understood how the requirement, distance-sensor.py, publisher script works, then the following subscriber script should be pretty straightforward to follow:

#!/usr/bin/env python

import rospy

from sensor_msgs.msg import Range

def callback(msg):

print msg.data

rospy.loginfo(rospy.get_caller_id() + 'GoPiGo3 measures distance %s mm', msg.data*1000)

rospy.init_node('distance_sensor_subscriber')

sub = rospy.Subscriber('distance_sensor/distance', Range, callback)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.