5 from geometry_msgs.msg
import Twist
10 swfile =
"/dev/rtmotoren0" 11 lfile =
"/dev/rtmotor_raw_l0" 12 rfile =
"/dev/rtmotor_raw_r0" 15 while not rospy.is_shutdown():
17 with open(swfile,
"r") as f: 18 motor_power_status = f.readline().rstrip() 19 if motor_power_status ==
"0":
21 if motor_power_status ==
"1" and sound_count == 0:
22 subprocess.call(
"aplay $(rospack find raspimouse_control)/misc/ms_sound.wav", shell=
True)
24 if motor_power_status ==
"1":
25 with open(lfile,
"r") as lf, \ 26 open(rfile, "r") as rf: 27 lhz_str = lf.readline().rstrip() 28 rhz_str = rf.readline().rstrip() 43 vel.linear.x = (lhz + rhz) * 9 * math.pi / 160000.0
44 vel.angular.z = (rhz - lhz) * math.pi / 800.0
48 except rospy.ROSInterruptException:
52 if __name__ ==
"__main__":
53 rospy.init_node(
"virtual_motors")
54 pub = rospy.Publisher(rospy.get_namespace() +
"diff_drive_controller/cmd_vel", Twist, queue_size=10)