From 0b7bbd0497cf39723116921ebb9bf6fb62934977 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 19 Mar 2025 17:26:29 +0100 Subject: [PATCH] BB2B-nw works! --- Examples/BB2B_networking.py | 8 ++++---- LinearAlgebra/Angle.py | 4 ++-- LocalParticipant.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/BB2B_networking.py b/Examples/BB2B_networking.py index 58046c1..7f5ea8c 100644 --- a/Examples/BB2B_networking.py +++ b/Examples/BB2B_networking.py @@ -36,17 +36,17 @@ touch_right.SetPosition(Spherical(0.12, Direction.Degrees(30, 0))) while True: # The left wheel turns forward when nothing is touched on the right side # and turn backward when the roboid hits something on the right - wheel_speed_left = 600 #-600 if touch_right.touched_something else 600 + wheel_speed_left = -600 if touch_right.touched_something else 600 # The right wheel does the same, but instead is controlled by # touches on the left side wheel_speed_right = -600 if touch_left.touched_something else 600 # When both sides are touching something, both wheels will turn backward # and the roboid will move backwards bb2b.SetWheelVelocity(wheel_speed_left, wheel_speed_right) - if touch_left.touched_something: - print(f'{wheel_speed_left} {wheel_speed_right} {bb2b.linear_velocity.distance} {bb2b.linear_velocity.direction.horizontal}') + if touch_left.touched_something or touch_right.touched_something: + print(f'{wheel_speed_left} {wheel_speed_right} {bb2b.linear_velocity.distance} {bb2b.angular_velocity.distance}') # Update the roboid state participant.Update() # and sleep for 100ms - time.sleep(1.0) + time.sleep(0.1) diff --git a/LinearAlgebra/Angle.py b/LinearAlgebra/Angle.py index aeba133..f4741c9 100644 --- a/LinearAlgebra/Angle.py +++ b/LinearAlgebra/Angle.py @@ -6,8 +6,8 @@ class Angle: @staticmethod def Normalize(angle): - while angle <= -180: + while angle < -180: angle += 360 - while angle > 180: + while angle >= 180: angle -= 360 return angle \ No newline at end of file diff --git a/LocalParticipant.py b/LocalParticipant.py index 5b1e9be..e828e34 100644 --- a/LocalParticipant.py +++ b/LocalParticipant.py @@ -133,7 +133,7 @@ class LocalParticipant(Participant): if buffer_size <= 0: return True - print(f'{self.name} send {self.buffer[0]} to {owner.ip_address} {owner.port}') + # print(f'{self.name} send {self.buffer[0]} to {owner.ip_address} {owner.port}') self.udp_socket.sendto(self.buffer[:buffer_size], (owner.ip_address, owner.port)) return True @@ -216,7 +216,7 @@ class LocalParticipant(Participant): print(f'received model url: {msg.url}') def ProcessBinaryMsg(self, msg: BinaryMsg): - print('received binary data') + # print('received binary data') thing: Thing = self.Get(msg.network_id, msg.thing_id) if thing != None: thing.ProcessBinary(msg.data)