4 from geometry_msgs.msg
import Twist
5 from sensor_msgs.msg
import Range
11 ''' Robot class to add ROS support to RoDI''' 14 hostname = rospy.get_param(
'~hostname',
'192.168.4.1')
15 port = rospy.get_param(
'~port',
'1234')
16 self.
timeout = rospy.get_param(
'~timeout', 2.0)
20 rospy.Subscriber(
'cmd_vel',
23 self.
pub = rospy.Publisher(
'ultrasound',
30 self.us_sensor.radiation_type = 0
31 self.us_sensor.header.frame_id =
"/ultrasound" 32 self.us_sensor.field_of_view = 0.52
33 self.us_sensor.min_range = 0.2
34 self.us_sensor.max_range = 1.0
40 if msg.angular.z == 0
and msg.linear.x == 0:
42 elif msg.linear.x > 0:
43 self.transport.move_forward()
44 elif msg.linear.x < 0:
45 self.transport.move_reverse()
46 elif msg.angular.z > 0:
47 self.transport.move_left()
48 elif msg.angular.z < 0:
49 self.transport.move_right()
52 while not rospy.is_shutdown():
57 range = self.transport.see()
59 self.us_sensor.range = float(range) / 100.0
60 self.us_sensor.header.stamp = rospy.Time.now()
62 except Exception
as exception:
63 rospy.logerr(
"getting sonar data failed: " + str(exception))
def _cmd_vel_cb(self, msg)