Skip to content

Conversation

leahkiner
Copy link
Contributor

Description

This PR adds a stepper motor simulation module to the repository. This kinematic profiler module is useful to simulate the actuation of prescribed spacecraft components. This PR is ported from the LASP-BSK repository, it has already had a series of reviews there.

The stepper motor module simulates the actuation of a stepper motor. Given the initial motor angle, a fixed motor step angle, a fixed motor step time, and an input message containing an integer number of steps commanded, the motor states are computed at each time step and output from the module. The motor states include the scalar motor angle, scalar angle rate, scalar angular acceleration, the current motor step count, and the number of steps commanded to the
motor. The motor actuation through each step of the command sequence is profiled using a bang-bang
acceleration profile. This module also includes logic for handling incoming reference commands that interrupt an
unfinished motor actuation sequence. Because the stepper motor is unable to stop actuating during a step, it must
finish actuating through the current step before it can begin following a new reference command.

Verification

The unit test is written to check nominal motor actuation and message interruptions to current motor actuation.

Documentation

RST documentation is added for the module.

Future work

N/A

@leahkiner leahkiner requested a review from schaubh September 9, 2025 22:02
@leahkiner leahkiner self-assigned this Sep 9, 2025
@leahkiner leahkiner requested a review from a team as a code owner September 9, 2025 22:02
@leahkiner leahkiner added the documentation Improvements or additions to documentation label Sep 9, 2025
@leahkiner leahkiner added the enhancement New feature or request label Sep 9, 2025
@leahkiner leahkiner moved this to 👀 In review in Basilisk Sep 9, 2025
@leahkiner leahkiner linked an issue Sep 9, 2025 that may be closed by this pull request
@schaubh schaubh changed the title Feature/1091 stepper motor simulation module Stepper Motor Simulation Module Sep 11, 2025
leahkiner and others added 12 commits September 13, 2025 09:05
If the return type is void, you can't include `@return void` in the method definition.
The auto-generated module header is the main section.  All module RST should use sub-section titles and lower
The titles are adjusted to be consistent with the rest of the BSK documentation.
I'm linking now to the unit test page. However, I feel the discussion of the testing is redundant.  The unit test files already have this documented and this module information is readily available one level higher going into module _UnitTest folder.  If these sections have info not in the python test method doc-strings, then add this info there and remove this testing info from the module.
Doxygen Method information was defined both in the *.h and *.cpp files.  This caused the RST to have repeated documentation statements.
@schaubh schaubh force-pushed the feature/1091-stepper-motor-simulation-module branch from 3004b47 to e885eef Compare September 13, 2025 21:36
/*
ISC License

Copyright (c) 2023, Autonomous Vehicle Systems Lab, University of Colorado at Boulder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update copyright year to 2025 as it is being contributed in 2025.

/*
ISC License

Copyright (c) 2023, Autonomous Vehicle Systems Lab, University of Colorado at Boulder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update year it was contributed


*/
%module stepperMotor
%{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add

%include "architecture/utilities/bskException.swg"
%default_bsk_exception();

after the %module line. This adds support for Mark's new way of having BSK errors float to python.

double t); //!< Method used to compute the motor states during the second half of each step
void computeStepComplete(double t); //!< Method used to compute the motor states when a step is complete

/* Step parameters */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add zero default values to all class variables. Unless the class instance is global or static, C++ will not zero-initialize the class variables.

assert(this->motorStepCommandInMsg.isLinked());

// Reset required module parameters
this->theta = this->thetaInit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, you create default values for some class variables in Reset(). I would still prefer all class variables have predictable default variables. Makes tracking down random behavior much easier in the future.

ISC License

Copyright (c) 2025, Laboratory for Atmospheric and Space Physics, University of Colorado at Boulder

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add AVS copyright statement. I pushed a [squash] labeled commit that does this.

ISC License

Copyright (c) 2025, Laboratory for Atmospheric and Space Physics, University of Colorado at Boulder

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add AVS copyright statement. I pushed a [squash] labeled commit that does this.

double StepperMotor::getThetaDDotMax() const { return this->thetaDDotMax; }

/*! Setter method for the initial motor angle.
@return void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These @return void statements raise warnings in sphinx and should be removed. I pushed a [squash] labeled commit that does this. CI Documentation now completes where before it failed.

StepperMotor() = default; //!< Constructor
~StepperMotor() = default; //!< Destructor

void Reset(uint64_t currentSimNanos) override; //!< Reset member function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods have doxygen documentation strings in both the *.h and *.cpp files. This caused the *.rst file to have repeated documentation text. Plus, it creates two places to update documentation in the future. A [squash] labeled commit was pushed which corrects this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Add stepper motor simulation module
2 participants