Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.. math::
velocity_{max} = \frac{\omega_{free} \cdot \pi \cdot d_{wheels} }{r_{gearing}}
acceleration_{max} = \frac{2 \cdot n \cdot \tau_{stall} \cdot r_{gearing} }{d_{wheels} \cdot m_{robot}}
k_{v} = \frac{V_{max}}{velocity_{max}}
k_{a} = \frac{V_{max}}{acceleration_{max}}
"""
# Check input units
# -> pint doesn't seem to support default args in check()
Helpers.ensure_mass(robot_mass)
Helpers.ensure_length(x_wheelbase)
Helpers.ensure_length(robot_width)
Helpers.ensure_length(robot_length)
Helpers.ensure_length(wheel_diameter)
max_velocity = (motor_config.freeSpeed * math.pi * wheel_diameter) / gearing
max_acceleration = (2.0 * nmotors * motor_config.stallTorque * gearing) / (
wheel_diameter * robot_mass
)
Helpers.ensure_velocity(max_velocity)
Helpers.ensure_acceleration(max_acceleration)
kv = motor_config.nominalVoltage / max_velocity
ka = motor_config.nominalVoltage / max_acceleration
kv = units.tm_kv.from_(kv, name="kv")
:param robot_mass: Mass of robot
:param x_wheelbase: Wheelbase of the robot
:param robot_width: Width of the robot
:param robot_length: Length of the robot
:param l_kv: Left side ``kv``
:param l_ka: Left side ``ka``
:param l_vi: Left side ``Vintercept``
:param r_kv: Right side ``kv``
:param r_ka: Right side ``ka``
:param r_vi: Right side ``Vintercept``
:param timestep: Model computation timestep
"""
# check input parameters
Helpers.ensure_mass(robot_mass)
Helpers.ensure_length(x_wheelbase)
Helpers.ensure_length(robot_width)
Helpers.ensure_length(robot_length)
Helpers.ensure_time(timestep)
logger.info(
"Robot base: %.1fx%.1f frame, %.1f wheelbase, %.1f mass",
robot_width.m,
robot_length.m,
x_wheelbase.m,
robot_mass.m,
)
self._lmotor = MotorModel(motor_config, l_kv, l_ka, l_vi)
self._rmotor = MotorModel(motor_config, r_kv, r_ka, r_vi)
self.inertia = (1 / 12.0) * robot_mass * (robot_length ** 2 + robot_width ** 2)
:param robot_length: Length of the robot
:param l_kv: Left side ``kv``
:param l_ka: Left side ``ka``
:param l_vi: Left side ``Vintercept``
:param r_kv: Right side ``kv``
:param r_ka: Right side ``ka``
:param r_vi: Right side ``Vintercept``
:param timestep: Model computation timestep
"""
# check input parameters
Helpers.ensure_mass(robot_mass)
Helpers.ensure_length(x_wheelbase)
Helpers.ensure_length(robot_width)
Helpers.ensure_length(robot_length)
Helpers.ensure_time(timestep)
logger.info(
"Robot base: %.1fx%.1f frame, %.1f wheelbase, %.1f mass",
robot_width.m,
robot_length.m,
x_wheelbase.m,
robot_mass.m,
)
self._lmotor = MotorModel(motor_config, l_kv, l_ka, l_vi)
self._rmotor = MotorModel(motor_config, r_kv, r_ka, r_vi)
self.inertia = (1 / 12.0) * robot_mass * (robot_length ** 2 + robot_width ** 2)
# This is used to compute the rotational velocity
self._bm = _bm_units.m_from((x_wheelbase / 2.0) * robot_mass)
:param motor_config: Motor specification
:param robot_mass: Mass of robot
:param x_wheelbase: Wheelbase of the robot
:param robot_width: Width of the robot
:param robot_length: Length of the robot
:param l_kv: Left side ``kv``
:param l_ka: Left side ``ka``
:param l_vi: Left side ``Vintercept``
:param r_kv: Right side ``kv``
:param r_ka: Right side ``ka``
:param r_vi: Right side ``Vintercept``
:param timestep: Model computation timestep
"""
# check input parameters
Helpers.ensure_mass(robot_mass)
Helpers.ensure_length(x_wheelbase)
Helpers.ensure_length(robot_width)
Helpers.ensure_length(robot_length)
Helpers.ensure_time(timestep)
logger.info(
"Robot base: %.1fx%.1f frame, %.1f wheelbase, %.1f mass",
robot_width.m,
robot_length.m,
x_wheelbase.m,
robot_mass.m,
)
self._lmotor = MotorModel(motor_config, l_kv, l_ka, l_vi)
self._rmotor = MotorModel(motor_config, r_kv, r_ka, r_vi)
* :math:`V_{max}` is the nominal max voltage of the motor
.. math::
velocity_{max} = \frac{\omega_{free} \cdot \pi \cdot d_{wheels} }{r_{gearing}}
acceleration_{max} = \frac{2 \cdot n \cdot \tau_{stall} \cdot r_{gearing} }{d_{wheels} \cdot m_{robot}}
k_{v} = \frac{V_{max}}{velocity_{max}}
k_{a} = \frac{V_{max}}{acceleration_{max}}
"""
# Check input units
# -> pint doesn't seem to support default args in check()
Helpers.ensure_mass(robot_mass)
Helpers.ensure_length(x_wheelbase)
Helpers.ensure_length(robot_width)
Helpers.ensure_length(robot_length)
Helpers.ensure_length(wheel_diameter)
max_velocity = (motor_config.freeSpeed * math.pi * wheel_diameter) / gearing
max_acceleration = (2.0 * nmotors * motor_config.stallTorque * gearing) / (
wheel_diameter * robot_mass
)
Helpers.ensure_velocity(max_velocity)
Helpers.ensure_acceleration(max_acceleration)
kv = motor_config.nominalVoltage / max_velocity
ka = motor_config.nominalVoltage / max_acceleration