This is part two of the servo controller journey, we assume that you have setup the controller already following part one.
For printing or modifying Kayra, you cloned her github repo already, however, the repo also contains all the needed software.
Make sure that you have one or more servos connected to the controller so that you see them move when you start controlling them via the PC serial connection.
Also connect the controller via USB-C to your PC, for the moment, the PC's USB port will be strong enough to move a couple of servos, IF they are not built into Kayra. For moving servos that are built in, you need to modify the controller's power supply (a chapter to write…).
The directory “/kayra/micropython” from Kayra's github repo contains the files, we're interested in in this chapter.
Please load “usbServos.py" in the Thonny interpreter onto the servo controller and let it run via the “play” button. Now, the controller is listening to commands via the serial connection of USB.
On the PC side, install the “pynput” (this is a Python library that allows for listening to key strokes directly) once, via
pip3 install pynput
Start the “interactiveServo.py” script, make sure that you specified the correct serial port in the line reading
s = serial.Serial("/dev/ttyACM1", 115200)
It may be ACM0 or ACM1 depending on the other serial devices that you have connected, usually it's ACM0.
When starting the script, the system is in “single servo mode” (PC will send a “sss” command to the controller, for “set single servo” followed by the servo number and the angle).
The concept of moving Kayra relies on three different levels:
Once the connection between the PC is established, you can toggle through the servos using the up and down cursor keys and move them in using the left and right cursor keys:
The script defines servo positions by angle / degree. The amount by which the servos should move can be adjusted by pressing digits one (1°), five (5°) and zero (10°).
You can “reset” (set it to angle zero) the selected servo by hitting the “z” key. Setting the servo to zero is also called “centering”, this is an absolutely important and obligatory step when assembling Kayra.
By default, the servo control software is writing into the “neutral” pose, this is the pose where Kayra starts from, a standing position.
So, when you hit the “p” key on your PC, you enter the “pose” mode, where you can add or select single poses that Kayra will take.
You can step through all stored poses using the up and down cursor keys. (PC will send a “sas” command to the controller, for “set all servos” followed by all servo values)
If you hit the "+" while in pose mode, you will add a new pose and will be prompted to enter a name for the pose, hitting “enter” will store the pose's name and select it so that all servo movements will be attributed to this pose.
In order to modify the currently selected pose, you need to change back to the Single Servo Mode by hitting “c” key (for “control”) .
to be implemented
At any time, you can hit “s” for save and “l” for load.