Skip to content
Snippets Groups Projects
Select Git revision
  • abff08d802f4f0735e223fe98b1540725446dacf
  • main default protected
  • julia-compatability
3 results

omnibot.py

Felix Agner's avatar
Felix Agner authored
abff08d8
History

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 (link here).

Installation

On linux: pip install git+https://gitlab.control.lth.se/processes/omnibot/omnibot.py

Usage

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]).

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 = "localhost"

with Connection(HOST) as bot:
        
        # Target speed for servos
        vset = 100

        # Go one way
        while time() < tstart + 3:
            t0 = time()

            # set speeds
            bot.set_speeds([vset,vset,vset])
            
            # print position
            print('x:'+bot.get_x())
            print('y:'+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_client.Dummybot import run_dummybot

# Insert suitable IP-adress
HOST = "localhost"
run_dummybot(HOST)

Support

felix.agner@control.lth.se

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.