DifferentialDrivetrainSim¶
- class wpilib.simulation.DifferentialDrivetrainSim(*args, **kwargs)¶
Bases:
pybind11_object
Overloaded function.
__init__(self: wpilib.simulation._simulation.DifferentialDrivetrainSim, plant: wpimath._controls._controls.system.LinearSystem_2_2_2, trackWidth: meters, driveMotor: wpimath._controls._controls.plant.DCMotor, gearingRatio: float, wheelRadius: meters, measurementStdDevs: List[float[7]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) -> None
Create a SimDrivetrain.
- Parameters:
plant – The LinearSystem representing the robot’s drivetrain. This system can be created with LinearSystemId::DrivetrainVelocitySystem() or LinearSystemId::IdentifyDrivetrainSystem().
trackWidth – The robot’s track width.
driveMotor – A DCMotor representing the left side of the drivetrain.
gearingRatio – The gearingRatio ratio of the left side, as output over input. This must be the same ratio as the ratio used to identify or create the plant.
wheelRadius – The radius of the wheels on the drivetrain, in meters.
measurementStdDevs – Standard deviations for measurements, in the form [x, y, heading, left velocity, right velocity, left distance, right distance]ᵀ. Can be omitted if no noise is desired. Gyro standard deviations of 0.0001 radians, velocity standard deviations of 0.05 m/s, and position measurement standard deviations of 0.005 meters are a reasonable starting point.
__init__(self: wpilib.simulation._simulation.DifferentialDrivetrainSim, driveMotor: wpimath._controls._controls.plant.DCMotor, gearing: float, J: kilogram_square_meters, mass: kilograms, wheelRadius: meters, trackWidth: meters, measurementStdDevs: List[float[7]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) -> None
Create a SimDrivetrain.
- Parameters:
driveMotor – A DCMotor representing the left side of the drivetrain.
gearing – The gearing on the drive between motor and wheel, as output over input. This must be the same ratio as the ratio used to identify or create the plant.
J – The moment of inertia of the drivetrain about its center.
mass – The mass of the drivebase.
wheelRadius – The radius of the wheels on the drivetrain.
trackWidth – The robot’s track width, or distance between left and right wheels.
measurementStdDevs – Standard deviations for measurements, in the form [x, y, heading, left velocity, right velocity, left distance, right distance]ᵀ. Can be omitted if no noise is desired. Gyro standard deviations of 0.0001 radians, velocity standard deviations of 0.05 m/s, and position measurement standard deviations of 0.005 meters are a reasonable starting point.
- class KitbotGearing¶
Bases:
pybind11_object
Represents a gearing option of the Toughbox mini. 12.75:1 – 14:50 and 14:50 10.71:1 – 14:50 and 16:48 8.45:1 – 14:50 and 19:45 7.31:1 – 14:50 and 21:43 5.95:1 – 14:50 and 24:40
- k10p71 = 10.71¶
- k12p75 = 12.75¶
- k5p95 = 5.95¶
- k7p31 = 7.31¶
- k8p45 = 8.45¶
- class KitbotMotor¶
Bases:
pybind11_object
- DualCIMPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- DualFalcon500PerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- DualMiniCIMPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- DualNEOPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- SingleCIMPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- SingleFalcon500PerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- SingleMiniCIMPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- SingleNEOPerSide = <wpimath._controls._controls.plant.DCMotor object>¶
- class KitbotWheelSize¶
Bases:
pybind11_object
- kEightInch = 0.2032¶
- kSixInch = 0.1524¶
- kTenInch = 0.254¶
- class State¶
Bases:
pybind11_object
- kHeading = 2¶
- kLeftPosition = 5¶
- kLeftVelocity = 3¶
- kRightPosition = 6¶
- kRightVelocity = 4¶
- kX = 0¶
- kY = 1¶
- clampInput(u: numpy.ndarray[numpy.float64[2, 1]]) numpy.ndarray[numpy.float64[2, 1]] ¶
Clamp the input vector such that no element exceeds the battery voltage. If any does, the relative magnitudes of the input will be maintained.
- Parameters:
u – The input vector.
- Returns:
The normalized input.
- static createKitbotSim(*args, **kwargs)¶
Overloaded function.
createKitbotSim(motor: wpimath._controls._controls.plant.DCMotor, gearing: float, wheelSize: meters, measurementStdDevs: List[float[7]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) -> wpilib.simulation._simulation.DifferentialDrivetrainSim
Create a sim for the standard FRC kitbot.
- Parameters:
motor – The motors installed in the bot.
gearing – The gearing reduction used.
wheelSize – The wheel size.
measurementStdDevs – Standard deviations for measurements, in the form [x, y, heading, left velocity, right velocity, left distance, right distance]ᵀ. Can be omitted if no noise is desired. Gyro standard deviations of 0.0001 radians, velocity standard deviations of 0.05 m/s, and position measurement standard deviations of 0.005 meters are a reasonable starting point.
createKitbotSim(motor: wpimath._controls._controls.plant.DCMotor, gearing: float, wheelSize: meters, J: kilogram_square_meters, measurementStdDevs: List[float[7]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) -> wpilib.simulation._simulation.DifferentialDrivetrainSim
Create a sim for the standard FRC kitbot.
- Parameters:
motor – The motors installed in the bot.
gearing – The gearing reduction used.
wheelSize – The wheel size.
J – The moment of inertia of the drivebase. This can be calculated using SysId.
measurementStdDevs – Standard deviations for measurements, in the form [x, y, heading, left velocity, right velocity, left distance, right distance]ᵀ. Can be omitted if no noise is desired. Gyro standard deviations of 0.0001 radians, velocity standard deviations of 0.05 m/s, and position measurement standard deviations of 0.005 meters are a reasonable starting point.
- dynamics(x: numpy.ndarray[numpy.float64[7, 1]], u: numpy.ndarray[numpy.float64[2, 1]]) numpy.ndarray[numpy.float64[7, 1]] ¶
- getCurrentDraw() amperes ¶
Returns the currently drawn current.
- getGearing() float ¶
Returns the current gearing reduction of the drivetrain, as output over input.
- getHeading() wpimath.geometry._geometry.Rotation2d ¶
Returns the direction the robot is pointing.
Note that this angle is counterclockwise-positive, while most gyros are clockwise positive.
- getLeftCurrentDraw() amperes ¶
Returns the currently drawn current for the left side.
- getLeftPosition() meters ¶
Get the left encoder position in meters.
- Returns:
The encoder position.
- getLeftPositionFeet() feet ¶
- getLeftPositionInches() inches ¶
- getLeftVelocity() meters_per_second ¶
Get the left encoder velocity in meters per second.
- Returns:
The encoder velocity.
- getLeftVelocityFps() feet_per_second ¶
- getPose() wpimath.geometry._geometry.Pose2d ¶
Returns the current pose.
- getRightCurrentDraw() amperes ¶
Returns the currently drawn current for the right side.
- getRightPosition() meters ¶
Get the right encoder position in meters.
- Returns:
The encoder position.
- getRightPositionFeet() feet ¶
- getRightPositionInches() inches ¶
- getRightVelocity() meters_per_second ¶
Get the right encoder velocity in meters per second.
- Returns:
The encoder velocity.
- getRightVelocityFps() feet_per_second ¶
- setGearing(newGearing: float) None ¶
Sets the gearing reduction on the drivetrain. This is commonly used for shifting drivetrains.
- Parameters:
newGearing – The new gear ratio, as output over input.
- setInputs(leftVoltage: volts, rightVoltage: volts) None ¶
Sets the applied voltage to the drivetrain. Note that positive voltage must make that side of the drivetrain travel forward (+X).
- Parameters:
leftVoltage – The left voltage.
rightVoltage – The right voltage.
- setPose(pose: wpimath.geometry._geometry.Pose2d) None ¶
Sets the system pose.
- Parameters:
pose – The pose.
- setState(state: numpy.ndarray[numpy.float64[7, 1]]) None ¶
Sets the system state.
- Parameters:
state – The state.
- update(dt: seconds) None ¶
Updates the simulation.
- Parameters:
dt – The time that’s passed since the last Update(units::second_t) call.