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

omnibot.py

  • Clone with SSH
  • Clone with HTTPS
  • 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) 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
            
            # 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 = "localhost"
    run_dummybot(HOST)

    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.

    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.