Developers>Tutoriels>Move the robot
In this tutorial you will learn to move the MRPi1 robot.
- forward
- back
- turn left and right
Robot base
The MRPi1 robot is a differential wheeled robot based on two separately driven wheels and one free turning wheel.
Forward
- Start the python program :
$ python
- import the mrpi1_lib library :
$ from mrpi1_lib import *
- move the robot :
>>> forward(20)
This function allows to move the robot with a speed of 20 %. Speed is a value between 0 and 100%. The maximum speed is 100%.
- Stop the robot :
>>> stop()
Forward & back
Then leave python interpreter to create a script :
>>> exit()
- You can create a python script with the editor of your choice, for me I use Notepad++ and then I transfer the script to the Raspberry Pi via the FileZilla software.
- Exemple :
Name : move1.py
#!/usr/bin/python from mrpi1_lib import * import time forward(50) time.sleep(2) stop() time.sleep(1) back(50) time.sleep(2) stop()
- Then, you must make it executable with the command :
$ chmod +x move1.py
- Run program :
$ ./move1.py
The robot must :
- Start of program
- Forward for 2 seconds
-
Stop for 1 second
-
Back for 2 seconds
- Stop
- End program
Turn
- Exemple :
Name : move2.py
#!/usr/bin/python from mrpi1_lib import * import time turnRight(30) time.sleep(2) stop() time.sleep(0.5) turnLeft(20) time.sleep(1) stop()
- Run program :
$ ./move2.py
The robot must :
- Start of program
- Turn right for 2 seconds
-
Stop for 0.5 second
-
Turn left for 1 second
- Stop
- End program


