-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Let's set up a simple project to get started: here we will use the Python 3 client to communicate with the server.
- Python 3
- 1 x Poppy Ergo Jr robot
- 1 x OpenCM9.04 dev board
First, install the required Python dependencies for the server:
python -m pip install ikpy osc4py3 websockets pyserial
And then install the client by navigating to creative-extensions/python
and executing the following command to install the client:
python setup.py install
To start the server, you need to be at the root of the project's directory, or else it won't find the model file used to compute the inverse kinematic of a position.
We will start by using a dummy model to see if everything is set up correctly. To run the server, you need to execute the following command:
python sp-dr-server/main.py --protocol osc --dummy
And that's it ! The server is up and running.
Now that the server is running, connecting to it isn't complicated. Here's a very simple example of a script connecting to the server and sending a command:
from ergojunior.client import Client
client = Client('127.0.0.1', 9000) # Connect to the local server on port 9000
client.set_motor(1, 127.3) # Set the first motor at an angle of 127.3 degrees
Once you run this script, you should see a message looking like the following on the server's console:
DummyRobotControl: Set motor 1 to 127.30000305175781
If you do, you can now try to use your Ergo Jr with the server.
If you have never used your Ergo Jr, you may need to configure the motors. To do do, please disconnect all the motors from one another, and connect the first motor to the OpenCM board.
Now just upload the setup_motor.ino
embedded sketch, and the motor should be attributed a new ID.
Do the same steps for the 5 other motors, while changing the following line in setup_motor.ino
, with values from 2 to 6:
#define NEW_MOTOR_ID 1 // ID that will be attributed to the motor
Once you have uploaded the Arduino schema, check the Serial Monitor; the OpenCM will tell you when an ID has been assigned to the motor.
Once all the motors have an ID, you can reconnect the motors to one another.
Once the dev board is connected to your computer via USB, you have to find the port used for the serial connection with the board.
On Linux it should be something like /dev/ttyACM0
or /dev/ttyUSB0
and on Windows it should be something like COM1
(you can use the Device Manager on Windows to find it).
Once you found it, shut down and rerun the server using the following command (without the diamond <>
):
python sp-dr-server/main.py --protocol osc --serial-port <your_port>
And you're good to go ! Have fun !