Skip to content

Commit

Permalink
Added cg calculations for tippyness
Browse files Browse the repository at this point in the history
  • Loading branch information
prak132 committed Jan 13, 2025
1 parent 3ba2412 commit 75a6d37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/y2025/cpp/robot_cg_calculator.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "robot_cg_calculator.h"

#include <units/force.h>

namespace y2025 {

RobotCGCalculator::RobotCGCalculator() {
Expand All @@ -16,6 +18,11 @@ RobotCGCalculator::RobotCGCalculator() {
base_state_.velocity = {0_fps, 0_fps, 0_fps};
}

units::feet_per_second_t RobotCGCalculator::CalculateMaxAcceleration(units::inch_t distance_from_wheels) {
frc846::math::VectorND<units::inch, 3> cg = CalculateRobotCG();
return frc846::math::constants::physics::g * distance_from_wheels / cg[2] / 2;
}

void RobotCGCalculator::SetElevatorHeight(units::inch_t height) {
elevator_state_.position[2] = height;
}
Expand Down
2 changes: 2 additions & 0 deletions src/y2025/include/robot_cg_calculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class RobotCGCalculator {
void SetBaseHeight(units::inch_t height);
void SetBaseVelocity(frc846::math::VectorND<units::feet_per_second, 3> vel);

units::feet_per_second_t CalculateMaxAcceleration(units::inch_t distance_from_wheels);

/*
CalculateRobotCG()
Expand Down

0 comments on commit 75a6d37

Please sign in to comment.