Skip to content
Snippets Groups Projects
Commit caab129c authored by Felix Agner's avatar Felix Agner
Browse files

Changed to not have default port, to simplify connections via routers

parent 3e5963ea
Branches
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ pip install git+https://gitlab.control.lth.se/processes/omnibot/omnibot.py
## Usage
### Code
Import the connection-object with `from omnibot.tcp import Connection`. Use the `with Connection(HOST) as bot:` command, as this will automatically open and close the connection cleanly. To e.g. set the reference speed for servo 1 to 100, use `bot.set_speed(1,100)`. To set all servo speeds at once, use `bot.set_speeds([100,100,100])`.
Import the connection-object with `from omnibot.tcp import Connection`. Use the `with Connection(HOST, PORT) as bot:` command, as this will automatically open and close the connection cleanly. To e.g. set the reference speed for servo 1 to 100, use `bot.set_speed(1,100)`. To set all servo speeds at once, use `bot.set_speeds([100,100,100])`.
To read positions from the crazyflie, use
`x = bot.get_x()`,
......@@ -29,9 +29,10 @@ from omnibot.tcp import Connection
from time import time, sleep
# Insert suitable IP-adress
HOST = "localhost"
HOST = "192.168.0.101"
PORT = 9001
with Connection(HOST) as bot:
with Connection(HOST, PORT) as bot:
# Target speed for servos
vset = 100
......@@ -58,15 +59,16 @@ A pre-defined script which rotates first one way, then the other, and prints log
from omnibot.dummybot import run_dummybot
# Insert suitable IP-adress
HOST = "localhost"
run_dummybot(HOST)
HOST = "192.168.0.101"
PORT = 9001
run_dummybot(HOST, PORT)
```
### Maximum servo speed
You can get the maximum absolute value of servo-speed-setpoints with `max_speed = bot.get_max_speed()`. Any value above (below) `max_speed` (`-max_speed`) is rounded down (up) on the server side.
### Network
At the department of automatic control, you should be connected to the omnibots via the same router. Currently this has been done with the router with name *robotlab*, where the IP naming conventions for the robots are `192.168.0.10X` for robot with name `omniX`, i.e. omnibot `omni6` has IP `192.168.0.106`.
At the department of automatic control, you should be connected to the omnibots via the same router. Currently this has been done with the router with name *robotlab*. IP and port conventions: Robot with name *omniX* has IP `192.168.0.10X` and port `900X` e.g.. omnibot `omni10` has IP `192.168.0.110`and port `9006`.
## Support
felix.agner@control.lth.se
......
......@@ -5,7 +5,7 @@ from time import time, sleep
from .tcp import Connection
def run_dummybot(HOST,verbose=True):
def run_dummybot(HOST, PORT, verbose=True):
"""
Runs a dummybot at host HOST that rotates a bit while printing x and y coordinates.
"""
......@@ -13,7 +13,7 @@ def run_dummybot(HOST,verbose=True):
ts = 0.1 # sampling time
tstart = time()
with Connection(HOST,verbose=verbose) as bot:
with Connection(HOST,PORT,verbose=verbose) as bot:
print("Connected")
# Target speed for servos
......@@ -40,11 +40,13 @@ def run_dummybot(HOST,verbose=True):
if __name__ == '__main__':
# Server settings
HOST = "localhost"
PORT = 9998
if len(sys.argv) > 1:
if len(sys.argv) > 2:
# If an input is given to the script, it will be interpreted as the intended
# IP-address. Baseline is localhost.
# IP-address and port. Baseline is localhost, 9998.
HOST = sys.argv[1]
PORT = sys.argv[2]
print(f"HOST: \t {HOST}")
run_dummybot(HOST)
\ No newline at end of file
run_dummybot(HOST,PORT)
\ No newline at end of file
......@@ -5,10 +5,10 @@ class Connection(object):
to an omnibot.
HOST: Host name of server (string)
PORT: Port to connect to (int) (default 9998)
PORT: Port to connect to (int)
verbose: choose level of chit-chat (boolean)
"""
def __init__(self,HOST,PORT=9998,verbose=False):
def __init__(self,HOST,PORT,verbose=False):
self.HOST = HOST
self.PORT = PORT
self.verbose=verbose
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment