Robot control from the remote control

Example program

This article is automatically translated from Russian by Google Translator.

To control the robot with the remote control you need to write a program and run it on the robot.

Example of interaction with the remote control

  1. Write an algorithm to use the controller in TRIK Studio.

  2. Connect the controller to the computer and upload the written program to the robot.

  3. Connect your smartphone to the controller by selecting the controller's network.

  4. Open the TRIK Gamepad app on your smartphone.

  5. Execute the algorithm on the controller.

Program algorithm

1. Enter variables for gamepad touch coordinates - x and y - and initialize them by assigning zero values to them in the "Expression" block:

2. Add the "Wait for Gamepad Connect" block:

3. To check if the gamepad clicks on the left area (Pad1), add a "Condition" block with the condition gamepadPad1Pressed> 0:

4. In case there is no touch, it is necessary to stop the motors. To do this, add a block "Stop motors":

5. If the Pad1 area is pressed on the gamepad, you need to get the coordinates of the touch. To do this, use the gamepadPad1 array in the "Expression" block:

6. After getting the coordinates, add a simple controller with the "Motor Forward" blocks. The Y coordinate offset is responsible for the speed of the robot and the X coordinate offset is responsible for the rotation.

7. To close the condition, add a "Timer" block with a value of 100 ms (in the program this is the time for a new call to the remote control).

8. Close the loop on the "Condition" block with a link from the "Timer" block.

9. If you have a video camera, add the "Enable Video Streaming" block to the beginning of the program:

General view of the algorithm

You can find the finished program in the root folder of TRIK Studio /examples/trik/remoteControl or download it here.

Last updated