主要内容

derivative

Time derivative of bicycle vehicle model

Since R2021b

Description

stateDot = derivative(kinematicModel,state,cmds) returns the current state derivative, stateDot, as a three-element vector [xDot yDot thetaDot] for a bicycle kinematics vehicle motion model, kinematicModel. xDot and yDot refer to the vehicle velocity, specified in meters per second. thetaDot is the angular velocity of the vehicle heading, specified in radians per second.

example

Examples

collapse all

Create a robot and set its initial starting position and orientation.

kinematicModel = bicycleKinematics;
initialState = [0 0 0];

Set the timespan of the simulation to 1 s with 0.05 s time steps and the input commands to 2 m/s for the vehicle speed and pi/4 rad for the steering angle to create a left turn. Simulate the motion of the robot by using the ode45 solver on the derivative function.

tspan = 0:0.05:1;
inputs = [2 pi/4]; %Turn left
[t,y] = ode45(@(t,y)derivative(kinematicModel,y,inputs),tspan,initialState);

Plot the path.

figure
plot(y(:,1),y(:,2))

Figure contains an axes object. The axes object contains an object of type line.

Input Arguments

collapse all

Bicycle kinematic motion model, specified as a bicycleKinematics object.

Current vehicle state returned as a three-element vector of the form [x y theta].

x and y refer to the vehicle position, specified in meters per second. theta is the vehicle heading, specified in radians per second.

Input commands to the motion model, specified as a two-element vector. The VehicleInputs property value of motionModel determines the format of this command vector. These are the valid VehicleInputs values for a bicycleKinematics object:

  • "VehicleSpeedSteeringAngle" –– [v psi]

  • "VehicleSpeedHeadingRate" –– [v omegaDot]

v is the vehicle velocity in the direction of motion in meters per second. psi is the steering angle in radians. omegaDot is the angular velocity at the rear axle.

Output Arguments

collapse all

Derivative of current state, returned as a three-element vector of the form [xDot yDot thetaDot]. xDot and yDot refer to the vehicle velocity, returned in meters per second. thetaDot is the angular velocity of the vehicle heading, returned in radians per second.

References

[1] Lynch, Kevin M., and Frank C. Park. Modern Robotics: Mechanics, Planning, and Control. 1st ed. Cambridge, MA: Cambridge University Press, 2017.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2021b