Add constants
- Updated constants to correct values.
Change-Id: I62c7678e638cd0564605bc0824909532fc1bc854
diff --git a/y2017/BUILD b/y2017/BUILD
index aa423a8..8bb771c 100644
--- a/y2017/BUILD
+++ b/y2017/BUILD
@@ -13,5 +13,6 @@
'//aos/common/network:team_number',
'//aos/common:mutex',
'//frc971:constants',
+ '//y2017/control_loops/drivetrain:polydrivetrain_plants',
],
)
diff --git a/y2017/constants.cc b/y2017/constants.cc
index 0bd75c7..e636f95 100644
--- a/y2017/constants.cc
+++ b/y2017/constants.cc
@@ -1,8 +1,8 @@
#include "y2017/constants.h"
+#include <inttypes.h>
#include <math.h>
#include <stdint.h>
-#include <inttypes.h>
#include <map>
@@ -11,9 +11,12 @@
#endif
#include "aos/common/logging/logging.h"
-#include "aos/common/once.h"
-#include "aos/common/network/team_number.h"
#include "aos/common/mutex.h"
+#include "aos/common/network/team_number.h"
+#include "aos/common/once.h"
+
+#include "y2017/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
+#include "y2017/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -25,7 +28,15 @@
// ///// Mutual constants between robots. /////
const int Values::kZeroingSampleSize;
-constexpr double Values::kDrivetrainEncoderRatio;
+constexpr double Values::kDrivetrainEncoderRatio, Values::kShooterEncoderRatio,
+ Values::kIntakeEncoderRatio, Values::kIntakePotRatio,
+ Values::kHoodEncoderRatio, Values::kHoodPotRatio,
+ Values::kTurretEncoderRatio, Values::kTurretPotRatio,
+ Values::kIndexerEncoderRatio, Values::kIntakeEncoderIndexDifference,
+ Values::kIndexerEncoderIndexDifference,
+ Values::kTurretEncoderIndexDifference, Values::kHoodEncoderIndexDifference;
+constexpr ::frc971::constants::Range Values::kIntakeRange, Values::kHoodRange,
+ Values::kTurretRange;
namespace {
const uint16_t kCompTeamNumber = 971;
@@ -37,19 +48,97 @@
switch (team) {
case 1: // for tests
return new Values{
+ 5.0, // drivetrain max speed
+
+ // Intake
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Turret
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kTurretEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Hood
+ {
+ // Pot Offset
+ 0.1,
+ {Values::kZeroingSampleSize, Values::kHoodEncoderIndexDifference,
+ 0.1, 0.3},
+ },
0.0, // down error
+ "practice",
};
break;
case kCompTeamNumber:
return new Values{
+ 5.0, // drivetrain max speed
+
+ // Intake
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Turret
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kTurretEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Hood
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize, Values::kHoodEncoderIndexDifference,
+ 0.0, 0.3},
+ },
0.0, // down error
+ "competition",
};
break;
case kPracticeTeamNumber:
return new Values{
+ 5.0, // drivetrain max speed
+
+ // Intake
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Turret
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kTurretEncoderIndexDifference, 0.0, 0.3},
+ },
+
+ // Hood
+ {
+ // Pot Offset
+ 0.0,
+ {Values::kZeroingSampleSize, Values::kHoodEncoderIndexDifference,
+ 0.0, 0.3},
+ },
0.0, // down error
+ "practice",
};
break;
diff --git a/y2017/constants.h b/y2017/constants.h
index 1017dcd..92df517 100644
--- a/y2017/constants.h
+++ b/y2017/constants.h
@@ -2,6 +2,9 @@
#define Y2017_CONSTANTS_H_
#include <stdint.h>
+#include <math.h>
+
+#include "frc971/constants.h"
namespace y2017 {
namespace constants {
@@ -17,15 +20,83 @@
struct Values {
// ///// Mutual constants between robots. /////
// TODO(constants): Update/check these with what we're using this year.
+
static const int kZeroingSampleSize = 200;
// The ratio from the encoder shaft to the drivetrain wheels.
- // TODO(constants): Fix this.
- static constexpr double kDrivetrainEncoderRatio =
- (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0) /*encoder gears*/;
+ static constexpr double kDrivetrainEncoderRatio = 1.0 ;
+
+ // Ratios for our subsystems.
+ static constexpr double kShooterEncoderRatio = 32.0 / 48.0; //Encoder rotation to shooter wheel revolution
+ static constexpr double kIntakeEncoderRatio = (16 * 0.25) * (20 / 40) / (2.0 * numpy.pi) * 0.0254; //Encoder rotation per Meter(inch per radian) of movement
+ static constexpr double kIntakePotRatio = (16 * 0.25) / (2.0 * numpy.pi) * 0.0254; //Pot Rotation per Meter(inch per radian) of movement
+ static constexpr double kHoodEncoderRatio = 20.0 / 345.0; //Encoder rotation to Hood rotation
+ static constexpr double kHoodPotRatio = 20.0 / 345.0; //Pot Rotation per Hood rotation
+ static constexpr double kTurretEncoderRatio = 16.0 / 92.0; //Encoder rotation toTurret rotation
+ static constexpr double kTurretPotRatio = 16.0 / 92.0; //Pot Rotation per Turret rotation
+ static constexpr double kIndexerEncoderRatio = (18.0 / 36.0) * (12.0 / 84.0); //Encoder rotation to Inner indexer rotation
+
+ // Difference in radians between index pulses.
+ static constexpr double kIntakeEncoderIndexDifference =
+ 2.0 * M_PI * kIntakeEncoderRatio;
+ static constexpr double kIndexerEncoderIndexDifference =
+ 2.0 * M_PI * kIndexerEncoderRatio;
+ static constexpr double kTurretEncoderIndexDifference =
+ 2.0 * M_PI * kTurretEncoderRatio;
+ static constexpr double kHoodEncoderIndexDifference =
+ 2.0 * M_PI * kHoodEncoderRatio;
+
+ static constexpr ::frc971::constants::Range kIntakeRange{
+ // Lower hard stop in meters(inches)
+ -0.600 * 0.0254,
+ // Upper hard stop
+ 8.655 * 0.0254,
+ // Lower soft stop
+ 0.000,
+ // Upper soft stop
+ 8.530 * 0.0254};
+ static constexpr ::frc971::constants::Range kHoodRange{
+ // Lower hard stop in radians
+ -1.0 / 345.0 * 2.0 * M_PI,
+ // Upper hard stop in radians
+ 39.0 / 345.0 * 2.0 * M_PI,
+ // Lower soft stop in radians
+ 0.0,
+ // Upper soft stop in radians
+ (39.0 - 1.0) / 345.0 * 2.0 * M_PI};
+ static constexpr ::frc971::constants::Range kTurretRange{
+ // Lower hard stop in radians
+ -460.0 / 2.0 * M_PI / 180.0,
+ // Upper hard stop in radians
+ 460.0 / 2.0 * M_PI / 180.0,
+ // Lower soft stop in radians
+ -450.0 / 2.0 * M_PI / 180.0,
+ // Upper soft stop in radians
+ 450.0 / 2.0 * M_PI / 180.0};
// ///// Dynamic constants. /////
+ double drivetrain_max_speed;
+
+ struct Intake {
+ double pot_offset;
+ ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
+ };
+ Intake intake;
+
+ struct Turret {
+ double pot_offset;
+ ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
+ };
+ Turret turret;
+
+ struct Hood {
+ double pot_offset;
+ ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing;
+ };
+ Hood hood;
+
double down_error;
+ const char *vision_name;
};
// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
diff --git a/y2017/control_loops/python/hood.py b/y2017/control_loops/python/hood.py
index 376a22a..6ab8072 100755
--- a/y2017/control_loops/python/hood.py
+++ b/y2017/control_loops/python/hood.py
@@ -43,7 +43,7 @@
# Third axle gear ratio off the motor
self.G3 = self.G2 * (14.0 / 36.0)
# The last gear reduction (encoder -> hood angle)
- self.last_G = (18.0 / 345.0)
+ self.last_G = (20.0 / 345.0)
# Gear ratio
self.G = (12.0 / 60.0) * (14.0 / 36.0) * (14.0 / 36.0) * self.last_G
diff --git a/y2017/control_loops/python/indexer.py b/y2017/control_loops/python/indexer.py
index a5088cb..4797600 100755
--- a/y2017/control_loops/python/indexer.py
+++ b/y2017/control_loops/python/indexer.py
@@ -34,8 +34,8 @@
self.J_inner = 0.0269
self.J_outer = 0.0952
# Gear ratios for the inner and outer parts.
- self.G_inner = (12.0 / 48.0) * (18.0 / 48.0) * (24.0 / 36.0) * (16.0 / 72.0)
- self.G_outer = (12.0 / 48.0) * (18.0 / 48.0) * (30.0 / 422.0)
+ self.G_inner = (12.0 / 48.0) * (18.0 / 36.0) * (12.0 / 84.0)
+ self.G_outer = (12.0 / 48.0) * (18.0 / 36.0) * (24.0 / 420.0)
# Motor inertia in kg * m^2
self.motor_inertia = 0.000006
diff --git a/y2017/control_loops/superstructure/superstructure.q b/y2017/control_loops/superstructure/superstructure.q
index 4f854b7..b1e63bb 100644
--- a/y2017/control_loops/superstructure/superstructure.q
+++ b/y2017/control_loops/superstructure/superstructure.q
@@ -38,7 +38,8 @@
};
struct HoodGoal {
- // Angle the hood is currently at
+ // Angle the hood is currently at. An angle of zero hood is at the lower soft stop, angle
+ // increases as hood rises.
double angle;
// Caps on velocity/acceleration for profiling. 0 for the default.