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

Add killswitch for sentry based on gamestate #146

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ut-robomaster/src/drivers.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "tap/communication/serial/ref_serial_data.hpp"
#include "tap/drivers.hpp"

#include "communication/cv_board.hpp"
Expand All @@ -15,6 +16,11 @@ class Drivers : public tap::Drivers
communication::RttStream rtt;

bool isKillSwitched() { return !remote.isConnected(); }
bool isGameActive()
{
return this->refSerial.getGameData().gameStage ==
tap::communication::serial::RefSerialData::Rx::GameStage::IN_GAME;
}
}; // class Drivers

} // namespace src
11 changes: 9 additions & 2 deletions ut-robomaster/src/subsystems/chassis/command_sentry_position.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, we had a timer which would wait until the match starts to begin moving. Could you keep the timer but start it once the game officially starts? I.e. once the match starts, the Sentry will wait maybe 10 seconds before it starts moving, to avoid excess drift on the field.

Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ void CommandSentryPosition::execute()
spin = 0.0f;
}

chassis->input(move, spin);
if (drivers->isGameActive())
{
chassis->input(move, spin);
}
else
{
chassis->input(Vector2f(0.0f), 0.0f);
}
}

void CommandSentryPosition::end(bool) { chassis->input(Vector2f(0.0f), 0.0f); }
bool CommandSentryPosition::isFinished() const { return false; }

} // namespace commands
} // namespace commands