4 from std_msgs.msg
import Float32
12 Reading from the keyboard and Publishing Thrust Angles! 13 --------------------------- 14 Change Thrust Angle clockwise: h 15 Change Thrust Angle counter-clockwise: ; 17 r/v : increase/decrease thruster angle change speed by 10% 41 fd = sys.stdin.fileno()
42 oldattr = termios.tcgetattr(fd)
48 lflag = ~(termios.ICANON | termios.ECHOCTL)
50 lflag = ~(termios.ICANON | termios.ECHO)
52 termios.tcsetattr(fd, termios.TCSADRAIN, newattr)
53 ch = sys.stdin.read(1)
54 if echo
and ord(ch) == 127:
57 sys.stdout.write(
'\b \b')
59 termios.tcsetattr(fd, termios.TCSADRAIN, oldattr)
64 if __name__ ==
"__main__":
69 left_pub = rospy.Publisher(
'left_thrust_angle', Float32, queue_size=1)
70 right_pub = rospy.Publisher(
'right_thrust_angle', Float32, queue_size=1)
71 rospy.init_node(
'key2thrust_angle')
74 thrust_angle_speed = 0.1
75 max_angle = rospy.get_param(
"~max_angle", math.pi / 2)
82 print(
'Max Angle: {}'.format(max_angle))
87 if key
in moveBindings.keys():
89 curr_angle += thrust_angle_speed * moveBindings[key]
90 curr_angle = numpy.clip(curr_angle,
91 -max_angle, max_angle).item()
93 elif key
in speedBindings.keys():
95 thrust_angle_speed += (speedBindings[key] * 0.1 *
98 'thruster angle speed {} '.format(thrust_angle_speed))
101 if (num_prints == 14):
103 num_prints = (num_prints + 1) % 15
110 angle_msg.data = curr_angle
111 left_pub.publish(angle_msg)
112 right_pub.publish(angle_msg)
114 except Exception
as e:
121 left_pub.publish(angle_msg)
122 right_pub.publish(angle_msg)
def __gen_ch_getter(echo)