Difference between revisions of "MATLAB code"

From Bike Wiki
Jump to navigation Jump to search
(+)
(Sections)
Line 1: Line 1:
==How to make a cool animation of the bike==
+
== MATLAB files ==
# Clone https://github.com/CornellAutonomousBikeTeam/Matlab-Optimization, and open the folder in MATLAB
+
=== animateBike.m ===
# Open runBicycleTest.m
+
Inputs:
# In the command window, run something like <code>runBicycleTest(0,0,3,0,pi/6,0,0,[23,16,-2], 0,100,1)</code>. The penultimate parameter is the number of steps - that is, the bigger this is, the longer the simulation will run for. All the other parameters are basically documented in the variable names.
+
* state
 +
* p
 +
* motCommands
 +
* delta_offset
 +
* phi_offset
 +
=== balanceControlOptimizer.m ===
 +
=== BikeAndMotorConstants.m ===
 +
=== CircleAboutZ.m ===
 +
Inputs:
 +
* r - radius of the circle
 +
=== drawBike.m ===
 +
Inputs:
 +
* x
 +
* y
 +
* z
 +
* yaw
 +
* roll
 +
* steer
 +
* p
 +
=== lqr_BC_optimizer.m ===
 +
=== plotMultipleControllersTogether.m ===
 +
=== rhs.m ===
 +
* currentState
 +
* p
 +
* K
 +
* delta_offset
 +
* phi_offset
 +
=== runBicycleTest.m ===
 +
Inputs:
 +
* x0,y0 - intial location
 +
* v0 - initial speed
 +
* delta0 - intial steer angle
 +
* phi0 - intial lean angle
 +
* phi_dot0 - intial derivative of lean angle
 +
* psi0 - intial yaw angle (heading)
 +
* K - vector of gains (k1, k2, k3)
 +
* delta_offset - either a scalar (a constant offset), or a vector of offsets (the bike will attempt to hit delta_offset(n) at the nth timestep
 +
* numTimeSteps - the number of time steps to run the simulation for
 +
* graph - 1=  draws graph, 0 =does not
 +
=== testSteerOffset.m ===
  
 
== See also ==
 
== See also ==
 
* [[LQR]]
 
* [[LQR]]

Revision as of 20:45, 14 May 2020

MATLAB files

animateBike.m

Inputs:

  • state
  • p
  • motCommands
  • delta_offset
  • phi_offset

balanceControlOptimizer.m

BikeAndMotorConstants.m

CircleAboutZ.m

Inputs:

  • r - radius of the circle

drawBike.m

Inputs:

  • x
  • y
  • z
  • yaw
  • roll
  • steer
  • p

lqr_BC_optimizer.m

plotMultipleControllersTogether.m

rhs.m

  • currentState
  • p
  • K
  • delta_offset
  • phi_offset

runBicycleTest.m

Inputs:

  • x0,y0 - intial location
  • v0 - initial speed
  • delta0 - intial steer angle
  • phi0 - intial lean angle
  • phi_dot0 - intial derivative of lean angle
  • psi0 - intial yaw angle (heading)
  • K - vector of gains (k1, k2, k3)
  • delta_offset - either a scalar (a constant offset), or a vector of offsets (the bike will attempt to hit delta_offset(n) at the nth timestep
  • numTimeSteps - the number of time steps to run the simulation for
  • graph - 1= draws graph, 0 =does not

testSteerOffset.m

See also