Parameters are set in the config.json file. Starting position and orientation: .
- POST /goTo - send the bot to the destination. Json parameters: x,y - desired position, theta - desired orientation, v - maximum velocity, а - acceleration;
- GET /stop - stop the bot and reset destination;
- GET /pause - stop the bot without resetting the destination;
- GET /resume - resume moving to the destination;
- GET /status - returns a json with current position, orientation and velocity.
In order to control the bot it is necessary to specify the rotation velocity for each wheel - . Position and orientation of the bot are calculated using distance covered by each wheel. This model does not have encoders, so we assume we receive data for each wheel.
Angle error serves as input for the controller, the calculation is performed using atan2 function in order to limit the value .
For the integral part of the controller we calculate accumulated error, for the differential part - error delta:
Angle velocity is the output:
The destination is assumed to be reached, if bot's orientation and its distance from the goal are less than error value, specified in the config.json.
Formula for calculating distance:
The bot has three possible states: MOVING, PAUSED, STOPPED.
- State is switched to MOVING when POST GoTo is received;
- GET pause switches state to PAUSED, velocity is set to 0;
- GET stop swithces state to STOPPED, velocity is set to 0, goal resets;
- As soon as the goal is reached the bot switches its state to STOPPED;
- The bot can switch its state to PAUSED only if it was in the MOVING state before.