Skip to content

Commit ab12087

Browse files
committed
implement hardwareok in chassis
1 parent fddbfd2 commit ab12087

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

.DS_Store

8 KB
Binary file not shown.

ut-robomaster/src/subsystems/chassis/chassis_subsystem.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ void ChassisSubsystem::initialize()
3131

3232
void ChassisSubsystem::refresh()
3333
{
34+
setAmputated(hardwareOk());
3435
for (int8_t i = 0; i < WHEELS; i++)
3536
{
36-
wheels[i].setActive(!drivers->isKillSwitched());
37+
wheels[i].setActive(!drivers->isKillSwitched() && !isAmputated());
3738
wheels[i].updateVelocity(targetWheelVels[i] / M_TWOPI); // rad/s to rev/s
3839
}
3940

@@ -71,6 +72,19 @@ void ChassisSubsystem::runHardwareTests()
7172
// TODO
7273
}
7374

75+
bool ChassisSubsystem::hardwareOk()
76+
{
77+
for (int8_t i = 0; i < WHEELS; i++)
78+
{
79+
if (!wheels[i].isOnline())
80+
{
81+
return false;
82+
}
83+
}
84+
85+
return true;
86+
}
87+
7488
void ChassisSubsystem::input(Vector2f move, float spin)
7589
{
7690
Vector2f v = move * MAX_LINEAR_VEL;

ut-robomaster/src/subsystems/chassis/chassis_subsystem.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "modm/math/geometry.hpp"
77
#include "robots/robot_constants.hpp"
8+
#include "subsystems/subsystem.hpp"
89
#include "utils/motors/motor_controller.hpp"
910
#include "utils/power_limiter/power_limiter.hpp"
1011

@@ -18,7 +19,8 @@ namespace subsystems
1819
{
1920
namespace chassis
2021
{
21-
class ChassisSubsystem : public tap::control::Subsystem
22+
// class ChassisSubsystem : public tap::control::Subsystem
23+
class ChassisSubsystem : public UTSubsystem
2224
{
2325
public:
2426
ChassisSubsystem(src::Drivers* drivers);
@@ -31,6 +33,8 @@ class ChassisSubsystem : public tap::control::Subsystem
3133

3234
void runHardwareTests() override;
3335

36+
bool hardwareOk() override;
37+
3438
/// @brief Update robot motion based on simple input controls. Inputs are scaled and corrected
3539
/// to avoid over-driving motors. This logic can be adjusted to create various input schemes.
3640
/// @param move Linear movement (magnitude should be within [0,1])

0 commit comments

Comments
 (0)