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

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

parent 11313911
No related branches found
No related tags found
1 merge request!2Manual control user interface
...@@ -53,6 +53,7 @@ class ApiNode(Node): ...@@ -53,6 +53,7 @@ class ApiNode(Node):
publisher = self.publisher_topics[topic] publisher = self.publisher_topics[topic]
# Check if the topic is 'cmd_vel' and format the message as a Twist message # 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): if topic == "cmd_vel" and isinstance(message, tuple):
linear_x, angular_z = message linear_x, angular_z = message
twist_msg = Twist() twist_msg = Twist()
......
...@@ -26,7 +26,7 @@ class MessageHandler: ...@@ -26,7 +26,7 @@ class MessageHandler:
print(response.decode()) print(response.decode())
else: else:
client_socket.sendall(response) client_socket.sendall(response)
return "cmd_vel", (0, 0) return "cmd_vel", (0.0, 0.0)
def handle_ping(self, client_socket, _): def handle_ping(self, client_socket, _):
"""Responds with a PONG message.""" """Responds with a PONG message."""
......
...@@ -10,7 +10,8 @@ class MotorController(Node): ...@@ -10,7 +10,8 @@ class MotorController(Node):
self.wheel_radius = 0.05 # meters self.wheel_radius = 0.05 # meters
self.wheel_base = 0.30 self.wheel_base = 0.30
self.get_logger().info("hello") self.get_logger().info("hello")
left_pwm = 0
right_pwm = 0
def cmd_vel_callback(self, msg): def cmd_vel_callback(self, msg):
v = msg.linear.x v = msg.linear.x
...@@ -46,7 +47,9 @@ class MotorController(Node): ...@@ -46,7 +47,9 @@ class MotorController(Node):
elif v == -0.5: elif v == -0.5:
left_pwm = -75 left_pwm = -75
right_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}") 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