Skip to content

Detlaf/Diff-Drive-Robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Differential 2-wheel bot

Parameters are set in the config.json file. Starting position and orientation: .

Bot control via API:

  • 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.

Calculating covered distance (UpdateOdometry method):





Calculating new position and orientation (UpdateOdometry method):





Calculating velocity for each wheel (UnicycleToDifferential method):



PID-controller (GoToGoal method)

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:

States

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.

Releases

No releases published

Packages

No packages published

Languages