Fixed circular dependencies
This commit is contained in:
parent
5afe23ac66
commit
27e7f10589
14
README.md
14
README.md
@ -8,8 +8,18 @@ Supporting:
|
|||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
- Go to the root folder of this repository (the folder containing this `README.md` and `setup.py`)
|
You can install the package directly from the git server using pip:
|
||||||
- Execute the command.
|
```
|
||||||
|
pip install git+https://git.passer.life/RoboidControl/RoboidControl-python.git
|
||||||
|
```
|
||||||
|
If you want to use a specific branch, you can use
|
||||||
|
```
|
||||||
|
pip install git+https://git.passer.life/RoboidControl/RoboidControl-python.git@v0.4_dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively you can clone the repo to a folder in you project.
|
||||||
|
Then you can install it by going to the root folder of the repository (the folder containing this `README.md` and `setup.py`)
|
||||||
|
and execute the command.
|
||||||
```
|
```
|
||||||
pip install .
|
pip install .
|
||||||
```
|
```
|
||||||
|
@ -28,4 +28,4 @@ while True:
|
|||||||
# Update the roboid state
|
# Update the roboid state
|
||||||
bb2b.Update(True)
|
bb2b.Update(True)
|
||||||
# and sleep for 100ms
|
# and sleep for 100ms
|
||||||
time.sleep(100)
|
time.sleep(0.100)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from RoboidControl.Thing import Thing
|
#from RoboidControl.Thing import Thing
|
||||||
|
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ class Participant:
|
|||||||
|
|
||||||
# region Init
|
# region Init
|
||||||
|
|
||||||
#local_participant = None
|
local_participant = None
|
||||||
|
|
||||||
def __init__(self, ip_address: str = None, port: int = None) -> None:
|
def __init__(self, ip_address: str = None, port: int = None) -> None:
|
||||||
"""! Create a new participant with the given communcation info
|
"""! Create a new participant with the given communcation info
|
||||||
@ -30,16 +30,20 @@ class Participant:
|
|||||||
self.network_id: int = 0
|
self.network_id: int = 0
|
||||||
|
|
||||||
## The things managed by this participant
|
## The things managed by this participant
|
||||||
self.things: set[Thing] = set()
|
self.things: set['Thing'] = set()
|
||||||
|
|
||||||
|
from RoboidControl.Thing import Thing
|
||||||
Thing.CreateRoot(self)
|
Thing.CreateRoot(self)
|
||||||
|
|
||||||
self.buffer: bytearray = bytearray(256)
|
self.buffer: bytearray = bytearray(256)
|
||||||
|
|
||||||
|
def GetLocalParticipant():
|
||||||
|
return Participant.local_participant
|
||||||
|
|
||||||
def ReplaceLocalParticipant(newParticipant: 'Participant'):
|
def ReplaceLocalParticipant(newParticipant: 'Participant'):
|
||||||
Participant.localParticipant = newParticipant
|
Participant.localParticipant = newParticipant
|
||||||
|
|
||||||
def Get(self, thing_id: int) -> Optional[Thing]:
|
def Get(self, thing_id: int) -> Optional['Thing']:
|
||||||
"""! Get the thing with the given properties
|
"""! Get the thing with the given properties
|
||||||
|
|
||||||
@param thing_id The ID of the thing
|
@param thing_id The ID of the thing
|
||||||
@ -50,7 +54,7 @@ class Participant:
|
|||||||
return thing
|
return thing
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def Add(self, thing: Thing, check_id: bool = True):
|
def Add(self, thing: 'Thing', check_id: bool = True):
|
||||||
"""! Add a new thing for this participant.
|
"""! Add a new thing for this participant.
|
||||||
@param thing The thing to add
|
@param thing The thing to add
|
||||||
@param check_id If true, the thing.id is regenerated if it is zero
|
@param check_id If true, the thing.id is regenerated if it is zero
|
||||||
@ -63,7 +67,7 @@ class Participant:
|
|||||||
if found_thing == None:
|
if found_thing == None:
|
||||||
self.things.add(thing)
|
self.things.add(thing)
|
||||||
|
|
||||||
def Remove(self, thing: Thing) -> None:
|
def Remove(self, thing: 'Thing') -> None:
|
||||||
"""! Remove a thing for this participant
|
"""! Remove a thing for this participant
|
||||||
@param thing The thing to remove
|
@param thing The thing to remove
|
||||||
"""
|
"""
|
||||||
|
@ -74,7 +74,8 @@ class Thing:
|
|||||||
# self.owner.Add(self) missing????
|
# self.owner.Add(self) missing????
|
||||||
else:
|
else:
|
||||||
if parent is None:
|
if parent is None:
|
||||||
self.SetParent(Thing.LocalRoot())
|
from RoboidControl.Participant import Participant
|
||||||
|
self.SetParent(Participant.local_participant.root)
|
||||||
else:
|
else:
|
||||||
self.SetParent(parent)
|
self.SetParent(parent)
|
||||||
|
|
||||||
@ -110,9 +111,9 @@ class Thing:
|
|||||||
def CreateRoot(owner: 'Participant'):
|
def CreateRoot(owner: 'Participant'):
|
||||||
owner.root = Thing(owner = owner)
|
owner.root = Thing(owner = owner)
|
||||||
|
|
||||||
def LocalRoot() -> 'Thing':
|
# def LocalRoot() -> 'Thing':
|
||||||
participant = participant.localParticipant
|
# participant = Participant.GetLocalParticipant()
|
||||||
return participant.root
|
# return participant.root
|
||||||
|
|
||||||
# endregion Init
|
# endregion Init
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ class DifferentialDrive(Thing):
|
|||||||
"""! A thing which can move itself using a differential drive system
|
"""! A thing which can move itself using a differential drive system
|
||||||
@sa @link https://en.wikipedia.org/wiki/Differential_wheeled_robot @endlink
|
@sa @link https://en.wikipedia.org/wiki/Differential_wheeled_robot @endlink
|
||||||
"""
|
"""
|
||||||
def __init__(self, owner = None, parent = None, thing_id = 0):
|
def __init__(self, owner = None, parent = None):
|
||||||
"""! Create a differential drive
|
"""! Create a differential drive
|
||||||
"""
|
"""
|
||||||
super().__init__(owner = owner, parent = parent, thing_type = Thing.Type.DifferentialDrive, thing_id = thing_id)
|
super().__init__(owner = owner, parent = parent)
|
||||||
|
|
||||||
## The radius of a wheel in meters
|
## The radius of a wheel in meters
|
||||||
self.wheel_radius = 1.0
|
self.wheel_radius = 1.0
|
||||||
|
@ -6,8 +6,8 @@ class TouchSensor(Thing):
|
|||||||
def __init__(self, owner = None, parent = None, thing_id = 0):
|
def __init__(self, owner = None, parent = None, thing_id = 0):
|
||||||
"""! Create a touch sensor
|
"""! Create a touch sensor
|
||||||
"""
|
"""
|
||||||
super().__init__(owner = owner, parent = parent, thing_type = Thing.Type.TouchSensor, thing_id = thing_id)
|
super().__init__(owner = owner, parent = parent)
|
||||||
|
self.type = Thing.Type.TouchSensor
|
||||||
## Value which is true when the sensor is touching something, false otherwise
|
## Value which is true when the sensor is touching something, false otherwise
|
||||||
self.touched_something = False
|
self.touched_something = False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user