Mobile Robot Simulation and Control
? Maplesoft, a division of Waterloo Maple Inc., 2008
Given the model of a two wheel differential drive mobile robot, we would like to simulate its trajectory response to various inputs in both open and closed loop settings. The robot model has been derived in a separate application example worksheet titled Mobile Robot Modeling and Simulation .
System Definition
Robot System Model
Simulations
The robot has two independent wheels, each connected to a motor. This way the robot can move forward, back, and turn.
Define the Variables and the Parameters that describe the system.
Parameters
Name
Value
Units
Robot Parameters
Robot Chassis Radius ()
Robot Chassis Mass ()
Robot Chassis Moment of Inertia ()
Wheel Parameters
Wheel Radius ()
Wheel Mass ()
Wheel Moment of Inertia ()
Motor Parameters
DC Motor Armature Resistance ()
DC Motor Armature Inductance ()
DC Motor Torque Constants ()
DC Motor EMF Constants ()
# Retrieve Parameters Defined
Description
Robot State
Robot Position (x and y coordinates)
Robot Heading (counter clockwise from the x-axis when viewed from top)
Robot Linear Velocity (w.r.t. Body Fixed Frame, positive going forward)
Robot Angular Velocity (w.r.t. Body Fixed Frame, about vertical axis)
Wheel Variables
Wheel Angular Speed (left and right)
Wheel Applied Torque (left and right)
Wheel Traction Force (left and right)
Motor Variables
Motor Current (left and right)
Motor Input Voltage (left and right)
The model of the robot has been derived in the MobileRobotModel worksheet. The overall system of equations is given as follows:
Equations for the linear acceleration in the x and y direction and the angular acceleration:
Equations for the linear and angular velocities:
Equations for the angular velocities of the wheels:
Equations for the wheel torques:
Equations for the motor currents:
Simulation
Open Loop Case
Here, we specify the input voltage to each of the two motors and observe the system response (uncontrolled).
System Input
# Open Loop System Input
The inputs to the combined system are the applied voltage to the motor. For the simulation, they are defined as piecewise continuous functions.
System Initial Conditions
# Open Loop Initial Conditions
The robot is assumed to be at the origin at rest. The following initial conditions describe this state.
Robot initial conditions
Wheel initial conditions
Motor initial conditions
System Response
# Open Loop System Response
Robot X and Y Position
Robot Heading
Robot Chassis Linear and Angular Velocities
Trajectory Animation
Speed Control
We want to implement a proportional-integral PI controllers to control the linear and angular speeds. The linear speed determines how fast the robot is moving forward, while the angular speed determines how fast the robot is turning.
# Speed Control System Input
The following inputs are applied to the system. The robot will first turn (rotate), then start moving forward while rotating, and finally move forward without turning before coming to a stop.
Controller Definition
We will use two independent PI controllers to control the forward () and turning () speed of the robot.
The output of the PI controllers are the forward control input and the turning control input
where the error (and its integral) in and are defined as:
Parameter values for the Speed PI Controllers
Gain
Forward Speed Control
Turning Speed Control
Initial Conditions:
Substituting the forward and turning controls in and into the following, we get:
The forward speed controller drives both wheels forward, while the turning controller drives each wheel in opposite direction. As such, the forward and turning control inputs relate to the left and right motor inputs as follows:
Writing the motor inputs in terms of the forward and turning controls:
Substituting the numeric values of the controller gains, we get:
# Response with Speed Control
Forward Speed
Angular Speed
Motor Control Signals
Heading Control
Here, we specify the desired heading for the mobile robot to follow. The heading controller is implemented as an outer loop controller to the speed controlled robot system. Again, we will be using a PI controller in this example.
# Heading Control System Input
The following inputs are applied. The robot is asked to start moving forward and turning at the same time. Then it will keep moving forward while maintaining a constant heading. After that, it will turn again and eventually come to a stop while pointing at the desired heading.
Similar to the speed controller, a PI controller is used for the heading control. In this case, the output of the controller is the desired turning rate :
where the heading error (and its integral) is defined as:
Parameters for the Heading PI Controller:
# System Response with Heading
Heading