Skip to content
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

disable subsystems when hardware disconnects #153

Merged
merged 17 commits into from
Nov 19, 2024
Merged

Conversation

tildezero
Copy link
Member

resolves #149

(currently untested)

@github-actions github-actions bot added the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 8, 2024
@tildezero
Copy link
Member Author

hardware test results:

  • chassis only works when CAN is disconnected, not the weird other side port
  • yaw should disable when 1 of 2 doubleyawmotors is disconnected, not both

Copy link
Contributor

@calebchalmers calebchalmers left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together -- great work! I've added some comments for changes throughout the code if you could take a look at those.

With the UTSubsystem parent class, I have an idea which might simplify things a bit: Currently, each UTSubsystem has to run setAmputated(!hardwareOk()) manually on refresh, but really this can be done in the background for every subsystem. I think the best way to do this would actually subclass the CommandScheduler. i.e.

void CommandScheduler::run()
{
#ifndef PLATFORM_HOSTED
    uint32_t runStart = arch::clock::getTimeMicroseconds();
#endif

    // We can insert our custom hardware checks here:
    for (auto it = subMapBegin(); it != subMapEnd(); it++)
    {
        Subsystem *sub = *it;
        sub->setAmputated(sub->hardwareOk());
    }

    // This is the built-in hardware checking system
    if (runningHardwareTests)
    {
        // Call runHardwareTests on all subsystems in the registeredSubsystemBitmap
        // if a hardware test is not already complete
        for (auto it = subMapBegin(); it != subMapEnd(); it++)
        {
            Subsystem *sub = *it;
            if (!sub->isHardwareTestComplete())
            {
                sub->runHardwareTests();
            }
            sub->refresh();
        }
        return;
    }
(...)

Update: nevermind looks like you can't change the CommandScheduler so easily, so let's leave that for later.

.DS_Store Outdated Show resolved Hide resolved
demo.txt Outdated Show resolved Hide resolved
ut-robomaster/src/subsystems/chassis/chassis_subsystem.hpp Outdated Show resolved Hide resolved
ut-robomaster/src/subsystems/subsystem.hpp Outdated Show resolved Hide resolved
ut-robomaster/src/subsystems/turret/turret_subsystem.cpp Outdated Show resolved Hide resolved
@calebchalmers
Copy link
Contributor

@MChung04 this is similar to the hardware checks you're working on. Might be some helpful stuff in here or implementations that can be shared between the tasks

@calebchalmers
Copy link
Contributor

Looks like clang-format is mad about odometry_subsystem.cpp for some reason so this might need formatting again

@calebchalmers calebchalmers removed the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 10, 2024
@calebchalmers calebchalmers added this to the Fall 2024 milestone Nov 10, 2024
@calebchalmers calebchalmers added the feature New feature label Nov 10, 2024
@github-actions github-actions bot added the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 15, 2024
@tildezero
Copy link
Member Author

hardware test 2: seems like flywheel isn't turning off

@calebchalmers calebchalmers removed the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 19, 2024
@calebchalmers
Copy link
Contributor

Fixed the flywheel and hero build issue. I removed the subsystems:: qualification from all the Subsystem subclass references since the subsystems are already in that namespace, and there is no naming conflict (our parent class is the only one included in each subsystem).

Otherwise looks great -- thanks!

@github-actions github-actions bot added the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 19, 2024
@calebchalmers calebchalmers removed the needs-testing Code needs to be flashed to hardware and tested before merging label Nov 19, 2024
@calebchalmers calebchalmers merged commit 38bb8b8 into develop Nov 19, 2024
5 of 7 checks passed
@calebchalmers calebchalmers deleted the amputate branch November 19, 2024 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable individual subsystems if required hardware disconnects
3 participants