BB2B-nw works!

This commit is contained in:
Pascal Serrarens 2025-03-19 17:26:29 +01:00
parent 9b421c0044
commit 0b7bbd0497
3 changed files with 8 additions and 8 deletions

View File

@ -36,17 +36,17 @@ touch_right.SetPosition(Spherical(0.12, Direction.Degrees(30, 0)))
while True: while True:
# The left wheel turns forward when nothing is touched on the right side # The left wheel turns forward when nothing is touched on the right side
# and turn backward when the roboid hits something on the right # 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 # The right wheel does the same, but instead is controlled by
# touches on the left side # touches on the left side
wheel_speed_right = -600 if touch_left.touched_something else 600 wheel_speed_right = -600 if touch_left.touched_something else 600
# When both sides are touching something, both wheels will turn backward # When both sides are touching something, both wheels will turn backward
# and the roboid will move backwards # and the roboid will move backwards
bb2b.SetWheelVelocity(wheel_speed_left, wheel_speed_right) bb2b.SetWheelVelocity(wheel_speed_left, wheel_speed_right)
if touch_left.touched_something: if touch_left.touched_something or touch_right.touched_something:
print(f'{wheel_speed_left} {wheel_speed_right} {bb2b.linear_velocity.distance} {bb2b.linear_velocity.direction.horizontal}') print(f'{wheel_speed_left} {wheel_speed_right} {bb2b.linear_velocity.distance} {bb2b.angular_velocity.distance}')
# Update the roboid state # Update the roboid state
participant.Update() participant.Update()
# and sleep for 100ms # and sleep for 100ms
time.sleep(1.0) time.sleep(0.1)

View File

@ -6,8 +6,8 @@ class Angle:
@staticmethod @staticmethod
def Normalize(angle): def Normalize(angle):
while angle <= -180: while angle < -180:
angle += 360 angle += 360
while angle > 180: while angle >= 180:
angle -= 360 angle -= 360
return angle return angle

View File

@ -133,7 +133,7 @@ class LocalParticipant(Participant):
if buffer_size <= 0: if buffer_size <= 0:
return True 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)) self.udp_socket.sendto(self.buffer[:buffer_size], (owner.ip_address, owner.port))
return True return True
@ -216,7 +216,7 @@ class LocalParticipant(Participant):
print(f'received model url: {msg.url}') print(f'received model url: {msg.url}')
def ProcessBinaryMsg(self, msg: BinaryMsg): def ProcessBinaryMsg(self, msg: BinaryMsg):
print('received binary data') # print('received binary data')
thing: Thing = self.Get(msg.network_id, msg.thing_id) thing: Thing = self.Get(msg.network_id, msg.thing_id)
if thing != None: if thing != None:
thing.ProcessBinary(msg.data) thing.ProcessBinary(msg.data)