An API controller for the e-puck2 from GCtronic for Webots and Python3
Project description
First Steps
Welcome to the UNIFR API e-puck’s documentation.
unifr_api_epuck is a simple API wrapper that lets you control a real or simulated e-puck robot. Please find below the instructions to get started with the API for Python3.
Submitted by: David Roman Frischer
Object detection section by: Vincent Carrel
Supervisor: Dr. Julien Nembrini
documentation : https://unifr-api-epuck.readthedocs.io/en/latest/
Requirements
Python3.x on your computer.
Webots or a real e-puck.
How To Start
With Real Robots
How to install the package from your terminal.
$ pip install unifr_api_epuck
- How to implement
To import the package:
from unifr_api_epuck import wrapper
To create an instance of the robot:
#Put the IP address of your robot. MY_IP = '192.168.43.125' r = wrapper.get_robot(MY_IP)
To control the robot by calling its actions:
r.init_sensors() #initiates the sensors r.set_speed(-2, 2) #makes it turn around itself #infinite loop while r.go_on(): prox_values = r.get_prox() #gets the values of the proximity sensors print(prox_values) r.clean_up() #makes a reset
To run the file
$ python3 my_controller_file.py
With Webots
- How to install the package from your terminal.
$ pip install unifr_api_epuck
- How to implement your Python controller
To import the wrapper from the package:
from unifr_api_epuck import wrapper
To create an instance of the robot:
r = wrapper.get_robot()
To control the robot by calling its actions:
r.init_sensors() #initiates the sensors r.set_speed(-2, 2) #makes it turn around itself #infinite loop while r.go_on(): prox_values = r.get_prox() #gets the values of the proximity sensors print(prox_values) r.clean_up() #makes a reset
To run the file:
⏯ press play on Webots
Simple Example Code
from unifr_api_epuck import wrapper
ip_addr = '192.168.43.125'
r = wrapper.get_robot(ip_addr)
r.set_speed(2) #sets the speed of the wheels
r.init_sensors() #initiates the proximity sensor
#infinite loop
while r.go_on():
print(r.get_prox()) #prints the proximity sensor values on the terminal
#inserts some more code here to control your robot
r.clean_up()
Graphic User Interface
A GUI is available in the package. To start it, please run the following command:
$ python3 -m unifr_api_epuck -g
Sources
- Wifi Protocol between Robot <–> computer
https://www.gctronic.com/doc/index.php?title=e-puck2_PC_side_development#WiFi_2
- Webots
https://www.cyberbotics.com/doc/reference/nodes-and-api-functions
- Multiprocess
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.managers.SyncManager
https://stackoverflow.com/questions/2545961/how-to-synchronize-a-python-dict-with-multiprocessing
- Socket errors
- Pi-Puck
https://pi-puck.readthedocs.io/en/latest/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for unifr_api_epuck-1.3.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 074479b6eed554015256980a1d68b888e64b9f3193b9eb05168a4dc3a2575c8c |
|
MD5 | 00c461a0a8df9dabbcc2c9f40278fca5 |
|
BLAKE2b-256 | 357074eeac5c66898f499a350bae28aace8c7069e10053f87c5d60a5daa729fe |