4 from __future__
import print_function
6 from sensor_msgs.msg
import LaserScan
11 distance = int(range_value[0] * 1000)
12 if distance < 4: distance = 8 - distance
15 led_value = int(761000 / math.pow(distance, 1.66))
16 if led_value > 4000: led_value = 4000
17 if led_value < 15: led_value = 15
25 with open(
"/dev/rtlightsensor0",
"w")
as f:
26 print(
"%d %d %d %d" % tuple(data), file=f)
28 rospy.logerr(
"failed to open rtlightsensor0")
49 rospy.Subscriber(rospy.get_namespace() +
"rf_scan", LaserScan, sensor1_callback)
50 rospy.Subscriber(rospy.get_namespace() +
"rs_scan", LaserScan, sensor2_callback)
51 rospy.Subscriber(rospy.get_namespace() +
"ls_scan", LaserScan, sensor3_callback)
52 rospy.Subscriber(rospy.get_namespace() +
"lf_scan", LaserScan, sensor4_callback)
55 if __name__ ==
"__main__":
56 led_val = [15, 15, 15, 15]
57 rospy.init_node(
"sensor_data_converter", anonymous=
True)
def sensor2_callback(data)
def range_to_led(range_value)
def sensor1_callback(data)
def sensor4_callback(data)
def sensor3_callback(data)