omnibot.py
Description
This is a python package which allows connection (currently only TCP-based) with the omnibots at the Department of Automatic Control.
Note that this package covers the client side. For information about setting up the omnibot, see omnibotserver.py.
Installation
On linux:
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, 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()
,
y = bot.get_y()
,
z = bot.get_z()
,
theta = bot.get_theta()
.
Example: Connect to a robot at localhost, make it spin in a circle and read the x and y positions.
from omnibot.tcp import Connection
from time import time, sleep
# Insert suitable IP-adress
HOST = "xxx.xxx.xxx.xxx"
PORT = yyyy
with Connection(HOST, PORT) as bot:
# Target speed for servos
vset = 100
# Record start time
t0 = time()
# Go one way for 3 seconds
while time() < t0 + 3:
# set speeds
bot.set_speeds([vset,vset,vset])
# print position
print('x:'+str(bot.get_x()))
print('y:'+str(bot.get_y()))
sleep(0.1)
Example: A pre-defined script which rotates first one way, then the other, and prints logged angle:
from omnibot.dummybot import run_dummybot
# Insert suitable IP-adress
HOST = "xxx.xxx.xxx.xxx"
PORT = yyyy
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
The omnibots automatically connect to the router named "robotlab". You can connect to the omnibots via this router, IP 130.235.83.171
. Use port 90XX
to rout to bot number XX
, e.g. 9006
routs to bot number 6. In the example above you would use
HOST = "130.235.83.171"
PORT = 9006
to connect to bot number 6.
Support
Contributing
Please feel free to improve this as future projects happen at the department.
License
MIT-license.
Project status
The project is mostly updated when courses using the robots are ongoing.