Index>Robot Kit>Alter All in One Kit for RPi>Lesson 31 Servo Link Function Call (Dog)
No related product information!

Lesson 31 Servo Link Function Call (Dog)

1129

       In this lesson, we will learn the function calls of the Alter Dog robot's servo linkage. You need to prepare the installed Alter Dog robot.

image.png

image.png


31.1 Servo Link Function Call

Because understanding the bottom control function of the servo requires some mathematical knowledge, if you don't want to spend too much time and experience, you can directly call the API that we provide to call the function that controls the connecting rod, which can save a lot of time.

For convenience, first you need to put your own .py in the server folder, so that you do not need to specify the location when importing alterMove.

Knowing how to control the linkage mechanism of each leg is particularly important for better control of Alter Dog, because many subsequent functions, such as gait generation, standing up and squatting, self-balancing mode, etc., are implemented based on this basic function. We will explain the calling method in detail so that you can edit more actions for the Alter Dog robot according to your needs.


31.2 Learning the code program of link function call

Here we use Subline IDE to view and edit the code program of this lesson, please see the content of lesson 2 for specific methods. The specific code and comments are as follows:

In the file manager of the MobaXterm terminal, find the directory:

adeept_alter/server 

And open the code for this lesson: linkageCALL.py.

When using it, directly call the alterMove.linkageQ(leg, x, y) function. The parameter leg represents the four legs 1, 2, 3, and 4 of the robot, as shown in the following figure:

image.png 

The parameters x and y are the coordinates of the landing site. The greater the positive value of x, the more the landing site deviates toward the forward direction; the greater the positive value of y, the more deviating the landing site toward the ground.

When you control the location of each leg, you don't need to instantiate the Alter object, because the main purpose of instantiating the Alter object is for multi-threaded control. You can choreograph or edit other actions for the robot by programming the location and setting the appropriate delay time.

The following routines control the swing of the robot's 1, 2, 3, and 4 legs respectively, and you can intuitively understand the calling method of this function.

image.png




31.3 Run the code program of the link function call

1. Open the terminal software MobaXterm:


image.png


2. Log in to your Raspberry Pi (the way to log in to Raspberry Pi has been introduced in Lesson 1):

image.png


3. Enter the Course Code folder, this folder stores the sample code program to control the robot, enter the following command:

cd adeept_alter/server

image.png


4. Enter the command to display the contents of the current directory:

ls

image.png


5. linkageCALL.py is the sample code of this lesson, enter the command to run this program:

sudo  python3  linkageCALL.py

image.png


6.After successfully running the program, you can observe the movement of the robot's legs.