97 tty.setraw(sys.stdin.fileno())
98 rlist, _, _ = select([sys.stdin], [], [], timeout)
99 key = sys.stdin.read(1)
if rlist
else ""
100 termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
106 settings = termios.tcgetattr(sys.stdin)
112 acceleration: float = 0.0
113 steering: float = 0.0
123 acceleration = min(acceleration, 1.0)
127 acceleration = max(acceleration, -1.0)
130 steering += math.pi / 32
131 steering = min(steering, math.pi / 8)
134 steering += -math.pi / 32
135 steering = max(steering, -math.pi / 8)
137 elif key ==
"q" or key ==
"\x03":
141 pub_thread.update(acceleration, steering)
142 print(f
"\rAccel: {acceleration:.2f} | Steer: {steering:.2f}", end=
"\n")
143 update_needed =
False
145 except Exception
as e:
150 termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
Thread to publish control commands to the robot.
__init__(self, rate)
Constructor for the PublishThread class.
update(self, float acceleration, float steering_angle)
Update the control commands to be published.
get_key(settings, timeout)