Unicycle vehicle model
unicycleKinematics creates a unicycle vehicle model to simulate simplified
car-like vehicle dynamics. The state of the vehicle is defined as a three-element vector,
[x y theta], with a global xy-position, specified in
meters, and a vehicle heading angle, theta, specified in radians. This
model approximates a unicycle vehicle with a given wheel radius, WheelRadius, that can spin in place according to a heading angle,
theta. To compute the time derivative states for the model, use the
function with input commands and the current robot state.
creates a unicycle kinematic model object with default property values.
kinematicModel = unicycleKinematics
sets additional properties to the specified values. You can specify multiple properties
in any order.
kinematicModel = unicycleKinematics(Name,Value)
WheelRadius — Wheel radius of vehicle
0.1 (default) | positive numeric scalar
The wheel radius of the vehicle, specified in meters.
WheelSpeedRange — Range of vehicle wheel speeds
[-Inf Inf] (default) | two-element vector
The vehicle speed range is a two-element vector that provides the minimum and maximum vehicle speeds, [MinSpeed MaxSpeed], specified in meters per second.
VehicleInputs — Type of motion inputs for vehicle
"WheelSpeedHeadingRate" (default) | character vector | string scalar
VehicleInputs property specifies the format of the model
input commands when using the
derivative function. Options are specified as one of the following
"WheelSpeedHeadingRate"— Wheel speed and heading angular velocity, specified in radians per second.
"VehicleSpeedHeadingRate"— Vehicle speed and heading angular velocity, specified in radians per second.
|Time derivative of vehicle state|
Plot Path of Unicycle Kinematic Robot
Create a Robot
Define a robot and set the initial starting position and orientation.
kinematicModel = unicycleKinematics; initialState = [0 0 0];
Simulate Robot Motion
Set the timespan of the simulation to
1 s with
0.05 s time steps and the input commands to
10 m/s and a heading angular velocity of
pi/4 rad/s to do a left turn. Simulate the motion of the robot by using the
ode45 solver on the
tspan = 0:0.05:1; inputs = [10 pi/4]; %Constant speed and turning left [t,y] = ode45(@(t,y)derivative(kinematicModel,y,inputs),tspan,initialState);
 Lynch, Kevin M., and Frank C. Park. Modern Robotics: Mechanics, Planning, and Control 1st ed. Cambridge, MA: Cambridge University Press, 2017.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2019b