You are going to program the robot for moving forward from the initial position at the start of the simulation, in the center of the room.
The robot should stop after traveling a distance equal to the size of the tile, which is 2 m.
According to the specifications, the diameter of the wheels of the Pioneer 3DX robot is 195.3 mm.
In [ ]:
import packages.initialization
import pioneer3dx as p3dx
p3dx.init()
In the following program template, you must fill the gaps with the appropriate code.
The idea is to compute the turned angle of one of the encoders (no matter which one) as the difference between the current and initial values, then compute the traveled distance. The robot will move as long as this distance is lower than the target distance, then it will stop.
In [ ]:
target = ... # target distance
r = ... # wheel radius
initialEncoder = ...
distance = 0
while distance < target:
p3dx.move(2.5,2.5)
angle = ...
distance = ...
p3dx.move(0,0)
Sponsored by:
[![IEEE Robotics and Automation Society](../img/logo/ras.png "IEEE Robotics and Automation Society")](http://www.ieee-ras.org) | [![Cyberbotics](../img/logo/cyberbotics.png "Cyberbotics")](http://www.cyberbotics.com) | [![The Construct](../img/logo/theconstruct.png "The Construct")](http://www.theconstructsim.com) |
Follow us:
[![Facebook](../img/logo/facebook.png "Facebook")](https://www.facebook.com/RobotProgrammingNetwork) | [![YouTube](../img/logo/youtube.png "YouTube")](https://www.youtube.com/user/robotprogrammingnet) |