From 4e1cbfb2aa143b80acab8846390fdb1d2ec570e7 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 11 Mar 2025 17:21:47 +0100 Subject: [PATCH] Initial setup of the BB2B example --- DoxyGen/DoxyWarnLogfile.txt | 125 ++++++++++------------- DoxyGen/Doxyfile | 6 +- Examples/BB2B.py | 27 +++++ LinearAlgebra/Angle.py | 10 ++ Participant.py | 45 +++++++- Thing.py | 32 ++++-- Things/DifferentialDrive.py | 62 +++++++++++ {Sensors => Things}/TemperatureSensor.py | 0 Things/TouchSensor.py | 14 +++ 9 files changed, 237 insertions(+), 84 deletions(-) create mode 100644 Examples/BB2B.py create mode 100644 LinearAlgebra/Angle.py create mode 100644 Things/DifferentialDrive.py rename {Sensors => Things}/TemperatureSensor.py (100%) create mode 100644 Things/TouchSensor.py diff --git a/DoxyGen/DoxyWarnLogfile.txt b/DoxyGen/DoxyWarnLogfile.txt index 6613bdb..351e9b1 100644 --- a/DoxyGen/DoxyWarnLogfile.txt +++ b/DoxyGen/DoxyWarnLogfile.txt @@ -1,69 +1,56 @@ -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:42: warning: documented symbol 'controlcore.Participant.Participant::bool' was not declared or defined. -error: Project logo '//intranet/home/Afbeeldingen/PasserVR/Logos/Logo3NameRight100.png' specified by PROJECT_LOGO does not exist! -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:13: warning: Member SendTo(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:19: warning: Member Publish(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:67: warning: Member length (variable) of class controlcore.Messages.NetworkIdMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:69: warning: Member network_id (variable) of class controlcore.Messages.NetworkIdMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:5: warning: Member id (variable) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:13: warning: Member SendTo(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:19: warning: Member Publish(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:5: warning: Member id (variable) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:115: warning: Member __init__(self, network_id, thing) (function) of class controlcore.Messages.PoseMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:119: warning: Member Serialize(self, buffer_ref) (function) of class controlcore.Messages.PoseMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:13: warning: Member SendTo(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:19: warning: Member Publish(self, participant) (function) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:116: warning: Member network_id (variable) of class controlcore.Messages.PoseMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:117: warning: Member thing (variable) of class controlcore.Messages.PoseMsg is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Messages.py:5: warning: Member id (variable) of class controlcore.Messages.IMessage is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:27: warning: Member __init__(self, ipAddress="0.0.0.0", port=7681, remote=False, udp_socket=None) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:50: warning: Member GetParticipant(self, ip_address, port) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:60: warning: Member AddParticipant(self, ip_address, port) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:67: warning: Member Update(self, currentTimeMs=None) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:82: warning: Member SendThingInfo(self, thing) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:87: warning: Member Send(self, msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:96: warning: Member Publish(self, msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:109: warning: Member Receiver(self) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:121: warning: Member ReceiveData(self, data, remote_participant) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:141: warning: Member ProcessClientMsg(self, sender, ParticipantMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:144: warning: Member ProcessNetworkIdMsg(self, sender, NetworkIdMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:153: warning: Member ProcessInvestigateMsg(self, bytearray data) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:156: warning: Member ProcessThingMsg(self, ThingMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:168: warning: Member ProcessNameMsg(self, NameMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:171: warning: Member ProcessModelUrlMsg(self, ModelUrlMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:174: warning: Member ProcessBinary(self, BinaryMsg msg) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:180: warning: Member Register(self, constructor, thing_type) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:183: warning: Member OnNewThing(self, event_handler) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:186: warning: Member OnNewThingType(self, thing_type, event_handler) (function) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:28: warning: Member ip_address (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:29: warning: Member port (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:33: warning: Member thing_msg_processors (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:34: warning: Member new_thing_handlers (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:37: warning: Member udp_socket (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:17: warning: Member publishInterval (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:19: warning: Member buffer (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:22: warning: Member nextPublishMe (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:23: warning: Member others (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:24: warning: Member thread (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:25: warning: Member name (variable) of class controlcore.Participant.Participant is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:22: warning: Member __init__(self, network_id=0, thing_id=0, type=Type.Undetermined, parent=None, name=None) (function) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:43: warning: Member update(self, currentTime) (function) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:46: warning: Member ProcessBinary(self, data) (function) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:53: warning: Member Add(thing) (function) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:58: warning: Member Get(network_id, thing_id) (function) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:23: warning: Member network_id (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:24: warning: Member id (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:25: warning: Member type (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:27: warning: Member parent_id (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:31: warning: Member name (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:32: warning: Member model_url (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:34: warning: Member position (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:35: warning: Member orientation (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:36: warning: Member linearVelocity (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:37: warning: Member angularVelocity (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:39: warning: Member pose_updated (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:17: warning: Member Position (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:18: warning: Member Orientation (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:19: warning: Member LinearVelocity (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:20: warning: Member AngularVelocity (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:50: warning: Member allThings (variable) of class controlcore.Thing.Thing is not documented. -/Users/pascal/Documents/Dev/Python/controlcore/LinearAlgebra/SwingTwist.py:6: warning: Member __init__(self, Direction swing, float twist) (function) of class SwingTwist.SwingTwist is not documented. +warning: source 'images' is not a readable file or directory... skipping. +d:/Python/RoboidControl-python/LocalParticipant.py:61: warning: Member GetParticipant(self, ip_address, port) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:71: warning: Member AddParticipant(self, ip_address, port) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:93: warning: Member SendThingInfo(self, thing) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:98: warning: Member Send(self, msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:107: warning: Member Publish(self, msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:120: warning: Member Receiver(self) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:132: warning: Member ReceiveData(self, data, remote_participant) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:152: warning: Member ProcessClientMsg(self, sender, ParticipantMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:155: warning: Member ProcessNetworkIdMsg(self, sender, NetworkIdMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:164: warning: Member ProcessInvestigateMsg(self, bytearray data) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:167: warning: Member ProcessThingMsg(self, ThingMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:179: warning: Member ProcessNameMsg(self, NameMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:182: warning: Member ProcessModelUrlMsg(self, ModelUrlMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:185: warning: Member ProcessBinary(self, BinaryMsg msg) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:191: warning: Member Register(self, constructor, thing_type) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:194: warning: Member OnNewThing(self, event_handler) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:197: warning: Member OnNewThingType(self, thing_type, event_handler) (function) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:39: warning: Member ip_address (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:40: warning: Member port (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:44: warning: Member thing_msg_processors (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:45: warning: Member new_thing_handlers (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:48: warning: Member udp_socket (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:85: warning: Member nextPublishMe (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:27: warning: Member publishInterval (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:29: warning: Member buffer (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:32: warning: Member nextPublishMe (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:33: warning: Member others (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:34: warning: Member thread (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/LocalParticipant.py:35: warning: Member name (variable) of class RoboidControl-python.LocalParticipant.LocalParticipant is not documented. +d:/Python/RoboidControl-python/Messages/Messages.py:115: warning: Member __init__(self, network_id, thing) (function) of class RoboidControl-python.Messages.Messages.PoseMsg is not documented. +d:/Python/RoboidControl-python/Messages/Messages.py:119: warning: Member Serialize(self, buffer_ref) (function) of class RoboidControl-python.Messages.Messages.PoseMsg is not documented. +d:/Python/RoboidControl-python/Messages/Messages.py:116: warning: Member network_id (variable) of class RoboidControl-python.Messages.Messages.PoseMsg is not documented. +d:/Python/RoboidControl-python/Messages/Messages.py:117: warning: Member thing (variable) of class RoboidControl-python.Messages.Messages.PoseMsg is not documented. +d:/Python/RoboidControl-python/Messages/NetworkIdMsg.py:7: warning: Member id (variable) of class RoboidControl-python.Messages.NetworkIdMsg.NetworkIdMsg is not documented. +d:/Python/RoboidControl-python/Messages/NetworkIdMsg.py:8: warning: Member length (variable) of class RoboidControl-python.Messages.NetworkIdMsg.NetworkIdMsg is not documented. +d:/Python/RoboidControl-python/Messages/NetworkIdMsg.py:10: warning: Member network_id (variable) of class RoboidControl-python.Messages.NetworkIdMsg.NetworkIdMsg is not documented. +d:/Python/RoboidControl-python/Messages/ParticipantMsg.py:53: warning: Member SendTo(participant, network_id) (function) of class RoboidControl-python.Messages.ParticipantMsg.ParticipantMsg is not documented. +d:/Python/RoboidControl-python/Messages/ParticipantMsg.py:64: warning: Member Publish(participant, network_id) (function) of class RoboidControl-python.Messages.ParticipantMsg.ParticipantMsg is not documented. +d:/Python/RoboidControl-python/Messages/ParticipantMsg.py:41: warning: Member Serialized(buffer_ref, network_id) (function) of class RoboidControl-python.Messages.ParticipantMsg.ParticipantMsg is not documented. +d:/Python/RoboidControl-python/Messages/ParticipantMsg.py:21: warning: Member network_id (variable) of class RoboidControl-python.Messages.ParticipantMsg.ParticipantMsg is not documented. +d:/Python/RoboidControl-python/Thing.py:57: warning: Member update(self, currentTime) (function) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:60: warning: Member ProcessBinary(self, data) (function) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:38: warning: Member parent_id (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:54: warning: Member pose_updated (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:17: warning: Member Position (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:18: warning: Member Orientation (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:19: warning: Member LinearVelocity (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:20: warning: Member AngularVelocity (variable) of class RoboidControl-python.Thing.Thing is not documented. +d:/Python/RoboidControl-python/Thing.py:9: warning: Member Undetermined (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/Thing.py:11: warning: Member Switch (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/Thing.py:12: warning: Member DistanceSensor (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/Thing.py:13: warning: Member DirectionalSensor (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/Thing.py:14: warning: Member TemperatureSensor (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/Thing.py:15: warning: Member Animator (variable) of class RoboidControl-python.Thing.Thing.Type is not documented. +d:/Python/RoboidControl-python/LinearAlgebra/SwingTwist.py:6: warning: Member __init__(self, Direction swing, float twist) (function) of class SwingTwist.SwingTwist is not documented. diff --git a/DoxyGen/Doxyfile b/DoxyGen/Doxyfile index 5122b3e..60aa074 100644 --- a/DoxyGen/Doxyfile +++ b/DoxyGen/Doxyfile @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Control Core for Python" +PROJECT_NAME = "Roboid Control for Python" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -68,7 +68,7 @@ PROJECT_LOGO = //intranet/home/Afbeeldingen/PasserVR/Logos/Logo3NameRi # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = //intranet/web/passer_life/apis/ControlCore/Python/ +OUTPUT_DIRECTORY = //intranet/web/roboidcontrol_doc/Python # If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 # sub-directories (in 2 levels) under the output directory of each output format @@ -636,7 +636,7 @@ CASE_SENSE_NAMES = NO # scope will be hidden. # The default value is: NO. -HIDE_SCOPE_NAMES = NO +HIDE_SCOPE_NAMES = YES # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to diff --git a/Examples/BB2B.py b/Examples/BB2B.py new file mode 100644 index 0000000..b37741d --- /dev/null +++ b/Examples/BB2B.py @@ -0,0 +1,27 @@ +from Things.DifferentialDrive import DifferentialDrive +from Things.TouchSensor import TouchSensor +import time + +# The robot's propulsion is a differential drive +bb2b = DifferentialDrive() +# It has a touch sensor at the front left of the roboid +touch_left = TouchSensor(bb2b) +# and other one on the right +touch_right = TouchSensor(bb2b) + +# Do forever: +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 if touch_right.touched_somthing 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_somthing 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) + + # Update the roboid state + bb2b.Update(True) + # and sleep for 100ms + time.sleep(100) diff --git a/LinearAlgebra/Angle.py b/LinearAlgebra/Angle.py new file mode 100644 index 0000000..3fec226 --- /dev/null +++ b/LinearAlgebra/Angle.py @@ -0,0 +1,10 @@ +import math + +class Angle: + @property + def Rad2Deg(self): + return 360 / (math.pi * 2) + + @property + def Deg2Rad(self): + return (math.pi * 2) / 360 \ No newline at end of file diff --git a/Participant.py b/Participant.py index cadb02d..537bc0c 100644 --- a/Participant.py +++ b/Participant.py @@ -1,20 +1,59 @@ class Participant: + """! A participant is a device which manages things. + + It can communicate with other participant to synchronise the state of things. + This class is used to register the things the participant is managing. + It also maintains the communcation information to contact the participant. + It is used as a basis for the local participant, but also as a reference to remote participants. + """ def __init__(self, ip_address, port): + """! Create a new participant with the given communcation info + """ + + ## The Ip Address of a participant. When the participant is local, this contains 0.0.0.0 self.ip_addres = ip_address + ## The port number for UDP communication with the participant. This is 0 for isolated participants. self.port = port + ## The network Id to identify the participant. + ## @note This field is likely to disappear in future versions + self.networkId = 0 + + ## The things managed by this participant self.things = set({ None }) - def Add(self, thing): - thing.id = len(self.things) - self.things.add(thing) + def Add(self, thing, check_id): + """! Add a new thing for this participant. + @param thing The thing to add + @param check_id When true, the thing ID of the thing is checked. If it is 0, a new thing Id will be assigned. + """ + if check_id and thing.id == 0: + thing.id = len(self.things) + self.things.add(thing) + else: + found_thing = self.Get(thing.network_id, thing.id) + if found_thing == None: + self.things.add(thing) def Get(self, network_id, thing_id): + """! Find a thing managed by this participant + + @param network_id The network ID for the thing + @param thing_id The ID of the thing + @return The thing if found or nullptr when no thing has been found + @note The use of the network ID is likely to disappear in future versions. + """ for thing in self.things: if thing is not None: if thing.network_id == network_id and thing.id == thing_id: return thing return None + def Remove(self, thing): + """! Remove a thig for this participant + @param thing The thing to remove + """ + self.things.remove(thing) + ## Update all things def Update(self, currentTimeMs): for thing in list(self.things): diff --git a/Thing.py b/Thing.py index b01a0a1..d8533ac 100644 --- a/Thing.py +++ b/Thing.py @@ -1,13 +1,13 @@ from LinearAlgebra.Spherical import Spherical from LinearAlgebra.Quaternion import Quaternion -## A thing is the basic building block -# -## A thing is the basic building block class Thing: - """ A thing is the basic building block""" + """! A thing is the basic building block""" class Type: + """! Predefined thing types + """ Undetermined = 0x00 + # Sensor Switch = 0x01 DistanceSensor = 0x02 DirectionalSensor = 0x03 @@ -19,26 +19,40 @@ class Thing: LinearVelocity = 0x04 AngularVelocity = 0x08 - def __init__(self, network_id = 0, thing_id = 0, type=Type.Undetermined, parent=None, name=None): + def __init__(self, owner = None, network_id = 0, thing_id = 0, type = Type.Undetermined, parent = None, name = None): + """! Create a new thing """ + + ## The participant owning this thing + self.owner = owner + ## The network ID of this thing + ## @note This field will likely disappear in future versions self.network_id = network_id + ## The ID of the thing self.id = thing_id + ## The type of the thing self.type = type - if parent is None: - self.parent_id = 0 - else: + + ## The parent thing + self.parent = 0 + if parent is not None: self.parent_id = parent.id + ## The name of the thing self.name = name + ## An URL pointing to the location where a model of the thing can be found self.model_url = None + ## The position of the thing in local space, in meters self.position = Spherical.zero + ## The new orientation in local space self.orientation = Quaternion.identity + ## The linear velocity of the thing in local space, in meters per second self.linearVelocity = Spherical.zero + ## The angular velocity of the thing in local space, in degrees per second self.angularVelocity = Spherical.zero self.pose_updated = 0x00 # the bits indicate which fields have been updated - Thing.Add(self) def update(self, currentTime): pass diff --git a/Things/DifferentialDrive.py b/Things/DifferentialDrive.py new file mode 100644 index 0000000..4fd62cb --- /dev/null +++ b/Things/DifferentialDrive.py @@ -0,0 +1,62 @@ +from Thing import Thing +from LinearAlgebra.Spherical import Spherical +from LinearAlgebra.Direction import Direction +from LinearAlgebra.Angle import Angle + +class DifferentialDrive(Thing): + def __init__(self, participant = None): + super().__init__(participant) + + ## The radius of a wheel in meters + self.wheel_radius = 1.0 + ## The distance between the wheels in meters + self.wheel_separation = 1.0 + + self.wheel_left = None + self.wheel_right = None + + def SetDriveDimensions(self, wheel_diameter, wheel_separation): + if wheel_diameter < 0: + wheel_diameter = -wheel_diameter + self.wheel_radius = wheel_diameter / 2 + + if wheel_separation < 0: + wheel_separation = -wheel_separation + self.wheel_separation = wheel_separation + + self.SetMotors(self.wheel_left, self.wheel_right) + + def SetMotors(self, wheel_left, wheel_right): + distance: float = self.wheel_separation / 2 + + self.wheel_left = wheel_left + if self.wheel_left is not None: + self.wheel_left.SetPosition(Spherical(distance, Direction.Left)) + + self.wheel_right = wheel_right + if self.wheel_right is not None: + self.wheel_right.SetPosition(Spherical(distance, Direction.Right)) + + def SetWheelVelocity(self, speed_left, speed_right): + if self.wheel_left is not None: + self.wheel_left.SetAngularVelocity(Spherical(speed_left, Direction.Left)) + + if self.wheel_right is not None: + self.wheel_right.SetAngularVelocity(Spherical(speed_right, Direction.Right)) + + def Update(self, currentTimeMs, recursive = True): + # This assumes forward velocity only... + linear_velocity: Spherical = self.GetLinearVelocity().distance + + angular_velocity: Spherical = self.GetAngularVelocity() + angular_speed: float = angular_velocity.distance * Angle.Deg2Rad # in radians/sec + # Determine the rotation direction + if angular_velocity.direction.horizontal.InDegrees() < 0: + angular_speed = -angular_speed + + speed_left: float = (linear_velocity + angular_speed * self.wheel_left.GetPosition().distance) / self.wheel_radius * Angle.Rad2Deg + speed_right: float = (linear_velocity - angular_speed * self.wheel_right.GetPosition().distance) / self.wheel_radius * Angle.Rad2Deg + + self.SetWheelVelocity(speed_left, speed_right) + + diff --git a/Sensors/TemperatureSensor.py b/Things/TemperatureSensor.py similarity index 100% rename from Sensors/TemperatureSensor.py rename to Things/TemperatureSensor.py diff --git a/Things/TouchSensor.py b/Things/TouchSensor.py new file mode 100644 index 0000000..2179107 --- /dev/null +++ b/Things/TouchSensor.py @@ -0,0 +1,14 @@ +from Thing import Thing + +class TouchSensor(Thing): + def __init__(self, owner, parent): + super().__init__(owner, parent) + + ## Value which is true when the sensor is touching something, false otherwise + self.touched_somthing = False + + def GenerateBinary(bytes, ix_ref): + pass + + def ProcessBinary(bytes): + pass \ No newline at end of file