Skip to content
Snippets Groups Projects
Commit db72839b authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

The stop command didn't have floats + gave default values to pwm

parent 6d2651c2
No related branches found
No related tags found
1 merge request!2Manual control user interface
......@@ -53,6 +53,7 @@ class ApiNode(Node):
publisher = self.publisher_topics[topic]
# Check if the topic is 'cmd_vel' and format the message as a Twist message
self.get_logger().info(f"Publishing to {topic}: {message}")
if topic == "cmd_vel" and isinstance(message, tuple):
linear_x, angular_z = message
twist_msg = Twist()
......
......@@ -26,7 +26,7 @@ class MessageHandler:
print(response.decode())
else:
client_socket.sendall(response)
return "cmd_vel", (0, 0)
return "cmd_vel", (0.0, 0.0)
def handle_ping(self, client_socket, _):
"""Responds with a PONG message."""
......
......@@ -10,7 +10,8 @@ class MotorController(Node):
self.wheel_radius = 0.05 # meters
self.wheel_base = 0.30
self.get_logger().info("hello")
left_pwm = 0
right_pwm = 0
def cmd_vel_callback(self, msg):
v = msg.linear.x
......@@ -46,7 +47,9 @@ class MotorController(Node):
elif v == -0.5:
left_pwm = -75
right_pwm = -75
if v == 0:
left_pwm = 0
right_pwm = 0
self.get_logger().info(f"Left PWM: {left_pwm}, Right PWM: {right_pwm}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment