diff --git a/README.md b/README.md index 86f59189295445844fbaa94e42bdbcc152e5f05f..ff9549a0809a34fbe2373666efba6c57fe46cca6 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,33 @@ -## omnibot_client +## omnibot.py ## Description -This is a python package which allows TCP connection with the omnibots at the Department of Automatic Control. +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 convers the **client side**. For information about setting up the omnibot, see (link here). ## Installation -On linus: -`pip install git+https://gitlab.control.lth.se/processes/omnibot/omnibotclient.py` +On linux: +`pip install git+https://gitlab.control.lth.se/processes/omnibot/omnibot.py` ## Usage -Import the omnibot-object with -`from omnibot_client.Omnibot import OmniBot` -Use the `with` command to create an omnibot-object, as this will automatically open and close the connection cleanly. -`with OmniBot("localhost") as bot` -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) 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()` +`x = bot.get_x()`, +`y = bot.get_y()`, +`z = bot.get_z()`, +`theta = bot.get_theta()`. -Example: +*Example:* Connect to a robot at localhost, make it spin in a circle and read the x and y positions. ``` -from omnibot_client.Omnibot import OmniBot +from omnibot.tcp import Connection from time import time, sleep # Insert suitable IP-adress HOST = "localhost" -with OmniBot(HOST) as bot: +with Connection(HOST) as bot: # Target speed for servos vset = 100 @@ -51,7 +46,7 @@ with OmniBot(HOST) as bot: sleep(0.1) ``` -Example: +*Example:* A pre-defined script which rotates first one way, then the other, and prints logged angle: ``` from omnibot_client.Dummybot import run_dummybot diff --git a/src/omnibot_client/__init__.py b/src/omnibot/__init__.py similarity index 100% rename from src/omnibot_client/__init__.py rename to src/omnibot/__init__.py diff --git a/src/omnibot_client/Dummybot.py b/src/omnibot/dummybot.py similarity index 93% rename from src/omnibot_client/Dummybot.py rename to src/omnibot/dummybot.py index b9dcf7297d8449f92ec569041776ccf8120f7b8c..570a4da395e4430cf741695613807555b832e9ff 100644 --- a/src/omnibot_client/Dummybot.py +++ b/src/omnibot/dummybot.py @@ -2,7 +2,7 @@ import sys from time import time, sleep -from .Omnibot import OmniBot +from .tcp import Connection def run_dummybot(HOST,verbose=True): @@ -13,7 +13,7 @@ def run_dummybot(HOST,verbose=True): ts = 0.1 # sampling time tstart = time() - with OmniBot(HOST,verbose=verbose) as bot: + with Connection(HOST,verbose=verbose) as bot: print("Connected") # Target speed for servos diff --git a/src/omnibot_client/Omnibot.py b/src/omnibot/tcp.py similarity index 99% rename from src/omnibot_client/Omnibot.py rename to src/omnibot/tcp.py index 4482668bd9924abd3ed30d7429a38e7a9de31485..d5e4742ed7062315752413c514718d4a9467724d 100644 --- a/src/omnibot_client/Omnibot.py +++ b/src/omnibot/tcp.py @@ -1,6 +1,6 @@ import socket -class OmniBot(object): +class Connection(object): """ A class that implements a servo-client which is capable of sending servo speed-settings to an omnibot. diff --git a/src/omnibot_client/ControllerTest.py b/src/omnibot/testcontroller.py similarity index 97% rename from src/omnibot_client/ControllerTest.py rename to src/omnibot/testcontroller.py index 54787eb248d99d5fe6e354c277e411c900c9edac..d2244c5ca9cad394ee4eb1eb2a5b6387e4dd3aaa 100644 --- a/src/omnibot_client/ControllerTest.py +++ b/src/omnibot/testcontroller.py @@ -9,7 +9,7 @@ import threading # Controller from inputs import get_gamepad -from .Omnibot import OmniBot +from .tcp import Connection class ControllerState: """ @@ -84,7 +84,7 @@ def run_omnibot_with_controller(HOST,verbose=False): ts = 0.1 # sampling time - with OmniBot(HOST,verbose=verbose) as bot: + with Connection(HOST,verbose=verbose) as bot: while state.on: t0 = time()