class
FlywheelSimulator
Contents
Constructors, destructors, conversion operators
- FlywheelSimulator(double imass = 0.01, double ilinkLen = 1, double imuStatic = 0.1, double imuDynamic = 0.9, double itimestep = 0.01) explicit
- A simulator for an inverted pendulum.
- ~FlywheelSimulator() virtual
Public functions
- auto step() -> double
- Step the simulation by the timestep.
- auto step(double itorque) -> double
- Step the simulation by the timestep.
- void setExternalTorqueFunction(std::function<double(double angle, double mass, double linkLength)> itorqueFunc)
- Sets the torque function used to calculate the torque due to external forces.
- void setTorque(double itorque)
- Sets the input torque.
- void setMaxTorque(double imaxTorque)
- Sets the max torque.
- void setAngle(double iangle)
- Sets the current angle.
- void setMass(double imass)
- Sets the mass (kg).
- void setLinkLength(double ilinkLen)
- Sets the link length (m).
- void setStaticFriction(double imuStatic)
- Sets the static friction (N*m).
- void setDynamicFriction(double imuDynamic)
- Sets the dynamic friction (N*m).
- void setTimestep(double itimestep)
- Sets the timestep (sec).
- auto getAngle() const -> double
- Returns the current angle (angle in rad).
- auto getOmega() const -> double
- Returns the current omgea (angular velocity in rad / sec).
- auto getAcceleration() const -> double
- Returns the current acceleration (angular acceleration in rad / sec^2).
- auto getMaxTorque() const -> double
- Returns the maximum torque input.
Protected functions
- auto stepImpl() -> double virtual
Protected variables
- double inputTorque
- double maxTorque
- double angle
- double omega
- double accel
- double mass
- double linkLen
- double muStatic
- double muDynamic
- double timestep
- double I
- std::function<double(double, double, double)> torqueFunc
- const double minTimestep
Function documentation
okapi:: FlywheelSimulator:: FlywheelSimulator(double imass = 0.01,
double ilinkLen = 1,
double imuStatic = 0.1,
double imuDynamic = 0.9,
double itimestep = 0.01) explicit
A simulator for an inverted pendulum.
The center of mass of the system changes as the link rotates (by default, you can set a new torque function with setExternalTorqueFunction()).
double okapi:: FlywheelSimulator:: step()
Step the simulation by the timestep.
Returns | the current angle |
---|
double okapi:: FlywheelSimulator:: step(double itorque)
Step the simulation by the timestep.
Parameters | |
---|---|
itorque | new input torque |
Returns | the current angle |
void okapi:: FlywheelSimulator:: setExternalTorqueFunction(std::function<double(double angle, double mass, double linkLength)> itorqueFunc)
Sets the torque function used to calculate the torque due to external forces.
Parameters | |
---|---|
itorqueFunc | the torque function. The return value is the torque due to external forces |
This torque gets summed with the input torque.
For example, the default torque function has the torque due to gravity vary as the link swings: [](double angle, double mass, double linkLength) { return (linkLength * std::cos(angle)) * (mass * -1 * gravity); }
void okapi:: FlywheelSimulator:: setTorque(double itorque)
Sets the input torque.
Parameters | |
---|---|
itorque | new input torque |
The input will be bounded by the max torque.
void okapi:: FlywheelSimulator:: setMaxTorque(double imaxTorque)
Sets the max torque.
Parameters | |
---|---|
imaxTorque | new maximum torque |
The input torque cannot exceed this maximum torque.
void okapi:: FlywheelSimulator:: setAngle(double iangle)
Sets the current angle.
Parameters | |
---|---|
iangle | new angle |
void okapi:: FlywheelSimulator:: setLinkLength(double ilinkLen)
Sets the link length (m).
Parameters | |
---|---|
ilinkLen | new link length |
void okapi:: FlywheelSimulator:: setStaticFriction(double imuStatic)
Sets the static friction (N*m).
Parameters | |
---|---|
imuStatic | new static friction |
void okapi:: FlywheelSimulator:: setDynamicFriction(double imuDynamic)
Sets the dynamic friction (N*m).
Parameters | |
---|---|
imuDynamic | new dynamic friction |
void okapi:: FlywheelSimulator:: setTimestep(double itimestep)
Sets the timestep (sec).
Parameters | |
---|---|
itimestep | new timestep |
double okapi:: FlywheelSimulator:: getAngle() const
Returns the current angle (angle in rad).
Returns | the current angle |
---|
double okapi:: FlywheelSimulator:: getOmega() const
Returns the current omgea (angular velocity in rad / sec).
Returns | the current omega |
---|
double okapi:: FlywheelSimulator:: getAcceleration() const
Returns the current acceleration (angular acceleration in rad / sec^2).
Returns | the current acceleration |
---|
double okapi:: FlywheelSimulator:: getMaxTorque() const
Returns the maximum torque input.
Returns | the max torque input |
---|