-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic AM thread in SM #30
Conversation
- Added a function to RCControls struct to assign values from an existing object - Implemented basic SBUS input taking with SM - Updated CMAKE
- IWDG timeout is set to 1 second - Added MotorChannel drivers to CMake
…::outputToMotor handles it
ce36281
to
87f60a8
Compare
df7c938
to
4b40609
Compare
SystemManager/Src/SystemManager.cpp
Outdated
if (this->rcInputs_.arm >= (SBUS_MAX/2)) { | ||
am_input.roll = rcInputs_.roll; | ||
am_input.pitch = rcInputs_.pitch; | ||
am_input.yaw = rcInputs_.yaw; | ||
am_input.throttle = rcInputs_.throttle; | ||
AM::AttitudeManager::setControlInputs(am_input); | ||
} else { | ||
AM::AttitudeManager::setControlInputs(am_input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should add arm and disarm methods directly into AM, so as to ensure that we can't accidentally write some value to the motors if we are in a flight mode that does not just directly map the controller inputs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying we should add arm/disarm logic to AM::setControlInputs()
? I'm guessing you want to disarm based on some flightmode property.
watchdog_(&hiwdg), | ||
am_instance_(config::flightmodes[config::DEFAULT_FLIGHTMODE].flightmodeConstructor()) | ||
{ | ||
xTaskCreate(runAM, "AM Thread", 400U, (void*)&am_instance_, osPriorityNormal, &AM_handle_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember if anything else needs to be done to start a task (I don't think so though...). Were you able to test this on hardware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks promising.
I'm running the AM thread at a period of 1 second and the set AM instructions thread at a period of 2 seconds (which simply increments the AM control struct using the static getter and setter methods defined in AM).
The AM thread runControlLoopIteration()
seems to be picking up the new values at the regular interval.
am_instance->runControlLoopIteration(AM::AttitudeManager::getControlInputs()); | ||
vTaskDelayUntil(&xLastWakeTime, AM_PERIOD_MS); | ||
} | ||
} | ||
|
||
void SystemManager::flyManually() { | ||
for(;;){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where would this be called? I imagine it would ideally run repeatedly at the same rate as runAM so that it has up-to-date control inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called in main.cpp
when we create a SM thread that calls flyManually()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets get this money
Description
What was completed, changed, or updated?
flyManually()
SM member function to set throttle, yaw, pitch and roll via a setter to allow communication with AM which will operate the motors using PWM accordingly (via outputToMotor() method)runAM()
function to runrunControlLoopIteration()
at set frequencyWhy was this done (if applicable)?
Testing
What manual tests were used to validate the code?
What unit tests were used to validate the code?
Documentation
Milestone number and name:
Link to Asana task:
Link to Confluence documentation:
Reminders
Add reviewers to the PR
Mention the PR in the appropriate discord channel