test_stepperMotor
- test_stepperMotor.test_stepper_motor_interrupt(show_plots, steps_commanded_1, steps_commanded_2, interrupt_fraction)[source]
Verification Test Description
The interruption unit test ensures that the module correctly handles reference messages that interrupt an unfinished motor actuation sequence. The initial motor angle, motor step angle, and step time are not varied in the interruption test because these parameters were already varied in the nominal test. The interruption test interrupts the first command sequence after half of the commanded motor steps are completed. The time the second command message is written is determined using an interruption factor to specify what fraction of the next step is completed before the second command message is written. Interruption factors of 0 and 1 are also included to ensure the module correctly resets the motor states when the interruption falls precisely when a step is completed. A rest period of 5 seconds is added to the end of the simulation for clarity when viewing the generated plots.
Test Parameters
- Parameters:
steps_commanded_1 (int) – [steps] Number of steps commanded to the stepper motor (First)
steps_commanded_2 (int) – [steps] Number of steps commanded to the stepper motor (Second)
interrupt_fraction (float) – Specifies what step fraction is completed when the interrupted message is written
Description of Variables Being Tested
The motor angle, rate, acceleration, and step count are checked to converge to the reference values at the end of each simulation chunk.
- test_stepperMotor.test_stepper_motor_nominal(show_plots, motor_theta_init, steps_commanded_1, steps_commanded_2, step_angle, step_time)[source]
Verification Test Description
This nominal unit test ensures that the stepper motor simulation module correctly actuates the motor from an initial angle to a final reference angle, given an input integer number of commanded steps. The module outputs the motor scalar states (angle, angle rate, acceleration), the motor step count, and steps commanded as a function of time. The motor actuation is profiled using a bang-bang acceleration profile. The motor acceleration is calculated in the module using the given motor step angle and step time constants. The capability for the motor to actuate both forwards and backwards is checked by commanding both positive and negative steps to the module. Zero steps commanded are also included in the test to check that the module correctly updates the motor states for a zero command message.
Test Parameters
- Parameters:
motor_theta_init (float) – [rad] Initial stepper motor angle
steps_commanded_1 (int) – [steps] Number of steps commanded to the stepper motor (first command)
steps_commanded_2 (int) – [steps] Number of steps commanded to the stepper motor (second command)
step_angle (float) – [rad] Angle the stepper motor moves through for a single step (constant)
step_time (float) – [sec] Time required for a single motor step (constant)
Description of Variables Being Tested
The motor angle, rate, acceleration, and step count are checked to converge to the reference values at the end of each simulation chunk.