Application Center - Maplesoft

# Mobile Robot

You can switch back to the summary page by clicking here.

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 .

 The robot has two independent wheels, each connected to a motor. This way the robot can move forward, back, and turn.

System Definition

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

Variables

 Name 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)

Robot System Model

The model of the robot has been derived in the MobileRobotModel worksheet.  The overall system of equations is given as follows:

# Overall System Model

Equations for the linear acceleration in the x and y direction and the angular acceleration:

 (2.1)

Equations for the linear and angular velocities:

 (2.2)

Equations for the angular velocities of the wheels:

 (2.3)

 (2.4)

Equations for the wheel torques:

 (2.5)

Equations for the motor currents:

 (2.6)

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.

 (3.1.1.1)

 (3.1.1.2)

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

 (3.1.2.1)

Wheel initial conditions

 (3.1.2.2)

Motor initial conditions

 (3.1.2.3)

System Response

# Open Loop System Response

Robot X and Y Position

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.

System Input

# 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

 (3.2.2.1)

 (3.2.2.2)

where the error (and its integral) in and are defined as:

 (3.2.2.3)

 (3.2.2.4)

 (3.2.2.5)

 (3.2.2.6)

Parameter values for the Speed PI Controllers

 Gain Value Forward Speed Control Turning Speed Control

Initial Conditions:

 (3.2.2.7)

 (3.2.2.10)

 (3.2.2.11)

Substituting the forward and turning controls in and into the following, we get:

 (3.2.2.12)

 (3.2.2.13)

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:

 (3.2.2.8)

 (3.2.2.9)

Writing the motor inputs in terms of the forward and turning controls:

 >

Substituting the numeric values of the controller gains, we get:

 (3.2.2.14)

System Response

# Response with Speed Control

Forward Speed

Angular Speed

Motor Control Signals

Trajectory Animation

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.

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.

Controller Definition

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 :

 (3.3.2.1)

where the heading error (and its integral) is defined as:

 (3.3.2.2)

 (3.3.2.3)

Parameters for the Heading PI Controller:

Initial Conditions:

 (3.3.2.4)

Substituting the numeric values of the controller gains, we get:

 >

 (3.3.2.5)

System Response

Forward Speed

Angular Speed

Trajectory Animation