Merge remote-tracking branch 'brian/devel' into claw
diff --git a/bbb_cape/src/cape/encoder.c b/bbb_cape/src/cape/encoder.c
index ad59248..af68de3 100644
--- a/bbb_cape/src/cape/encoder.c
+++ b/bbb_cape/src/cape/encoder.c
@@ -5,7 +5,7 @@
#include "cape/util.h"
// Here is where each encoder is hooked up:
-// 0: PC6,PC7 TIM8
+// 0: PC6,PC7 TIM8(APB2)
// 1: PC0,PC1 EXTI0,EXTI1
// 2: PA0,PA1 TIM5(32)
// 3: PA2,PA3 TIM9.1,EXTI3
@@ -104,17 +104,18 @@
encoder4_value = new_value;
}
-static void encoder_setup(TIM_TypeDef *timer) {
+static void encoder_setup(TIM_TypeDef *timer, int fast) {
timer->CR1 =
- TIM_CR1_URS /* don't generate spurious update interrupts that
- might be shared with other timers */;
+ TIM_CR1_URS | /* don't generate spurious update interrupts that
+ might be shared with other timers */
+ (fast ? (1 << 8) : 0) /* divide filter clock by 2 on fast encoders */;
timer->SMCR = 3; // 4x quadrature encoder mode
timer->CCER = 0;
timer->CCMR1 =
TIM_CCMR1_CC2S_0 | /* input pin 2 -> timer input 2 */
TIM_CCMR1_CC1S_0 | /* input pin 1 -> timer input 1 */
- (3 << 4) |
- (3 << 12);
+ (0xE << 4) | /* divide filter clock by 32, need 6 in a row to trigger */
+ (0xE << 12) /* same for other input */;
timer->PSC = 0;
timer->EGR = TIM_EGR_UG;
timer->CR1 |= TIM_CR1_CEN;
@@ -168,25 +169,25 @@
gpio_setup_alt(GPIOA, 5, 1);
gpio_setup_alt(GPIOB, 3, 1);
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
- encoder_setup(TIM2);
+ encoder_setup(TIM2, 0);
gpio_setup_alt(GPIOA, 6, 2);
gpio_setup_alt(GPIOB, 5, 2);
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
- encoder_setup(TIM3);
+ encoder_setup(TIM3, 0);
gpio_setup_alt(GPIOB, 6, 2);
gpio_setup_alt(GPIOB, 7, 2);
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
- encoder_setup(TIM4);
+ encoder_setup(TIM4, 0);
gpio_setup_alt(GPIOA, 0, 2);
gpio_setup_alt(GPIOA, 1, 2);
RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
- encoder_setup(TIM5);
+ encoder_setup(TIM5, 0);
gpio_setup_alt(GPIOC, 6, 3);
gpio_setup_alt(GPIOC, 7, 3);
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN;
- encoder_setup(TIM8);
+ encoder_setup(TIM8, 1);
}
diff --git a/frc971/constants.cc b/frc971/constants.cc
index 7d85bd7..4fea843 100755
--- a/frc971/constants.cc
+++ b/frc971/constants.cc
@@ -45,6 +45,38 @@
uint16_t team = ::aos::network::GetTeamNumber();
LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
switch (team) {
+ case 1: // for tests
+ return new Values{
+ kCompDrivetrainEncoderRatio,
+ kCompLowGearRatio,
+ kCompHighGearRatio,
+ kCompLeftDriveShifter,
+ kCompRightDriveShifter,
+ true,
+ control_loops::MakeVClutchDrivetrainLoop,
+ control_loops::MakeClutchDrivetrainLoop,
+ // ShooterLimits
+ // TODO(ben): make these real numbers
+ {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
+ {-0.001778, 0.000762, 0, 0}, {-0.001778, 0.009906, 0, 0}, {0.006096, 0.026416, 0, 0},
+ shooter_zeroing_off_speed,
+ shooter_zeroing_speed
+ },
+ {0.5,
+ 0.1,
+ 0.1,
+ 0.0,
+ 1.57,
+ 0,
+ 0,
+ {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
+ {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
+ 0.01, // claw_unimportant_epsilon
+ 0.9, // start_fine_tune_pos
+ 4.0,
+ }
+ };
+ break;
case kCompTeamNumber:
return new Values{
kCompDrivetrainEncoderRatio,
@@ -58,7 +90,7 @@
// ShooterLimits
// TODO(ben): make these real numbers
{-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
- {-0.001778, 0.000762}, {-0.001778, 0.009906}, {0.006096, 0.026416},
+ {-0.001778, 0.000762, 0, 0}, {-0.001778, 0.009906, 0, 0}, {0.006096, 0.026416, 0, 0},
shooter_zeroing_off_speed,
shooter_zeroing_speed
},
@@ -67,8 +99,10 @@
0.1,
0.0,
1.57,
- {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
- {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05}, {1.0, 1.1}, {2.0, 2.1}},
+ 0,
+ 0,
+ {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
+ {0.0, 2.05, 0.02, 2.02, {-0.1, 0.05, 0, 0}, {1.0, 1.1, 0, 0}, {2.0, 2.1, 0, 0}},
0.01, // claw_unimportant_epsilon
0.9, // start_fine_tune_pos
4.0,
@@ -87,19 +121,28 @@
control_loops::MakeDogDrivetrainLoop,
// ShooterLimits
// TODO(ben): make these real numbers
- {-0.00127, 0.298196, -0.001524, 0.305054, 0.0149098,
- {-0.001778, 0.000762}, {-0.001778, 0.009906}, {0.006096, 0.026416},
+ {-0.000446, 0.300038, -0.001, 0.304354,
+ 0.014436,
+ {-2, 0.001786, 0.001786, -2}, {-2, -0.000446, -2, 0.026938}, {0.006096, 0.026416, 0, 0},
shooter_zeroing_off_speed,
shooter_zeroing_speed
},
{0.5,
0.2,
0.1,
- 0.0,
- 1.57,
- // TODO(austin): Radians...
- {-196.70, 121.42, 0.02, 2.02, {-196.92, -180.99}, {-15.17, -3.30}, {106.26, 129.55}},
- {-142.96, 179.45, 0.02, 2.02, {-147.01, -127.93}, {-17.84, -5.39}, {167.75, 192.25}},
+ -0.446558,
+ 0.90675,
+ -0.39110,
+ 0.843349,
+#if 0
+ separations (top, bottom)
+ hard min position:-0.253845, position:-0.001136,
+ soft min position:-0.244528, position:-0.047269,
+ soft max position:0.526326, position:-0.510872,
+ hard max position:0.517917, position:-0.582685,
+#endif
+ {-1.62102, 1.039699, -1.606248, 0.989702, {-1.65, -1.546252, -1.65, -1.548752}, {-0.13249, -0.02113, -0.134763, -0.021589}, {0.934024, 1.05, 0.92970, 1.05}},
+ {-1.420352, 1.348313, -1.161281, 1.264001, {-1.45, -1.283771, -1.45, -1.28468}, {-0.332476, -0.214984, -0.334294, -0.217029}, {1.248547, 1.37, 1.245366, 1.37}},
0.01, // claw_unimportant_epsilon
0.9, // start_fine_tune_pos
4.0,
diff --git a/frc971/constants.h b/frc971/constants.h
index 81c7887..3416a39 100755
--- a/frc971/constants.h
+++ b/frc971/constants.h
@@ -27,8 +27,10 @@
struct Values {
// This is useful for representing the 2 sides of a hall effect sensor etc.
struct AnglePair {
- double lower_angle;
- double upper_angle;
+ // The angles for increasing values (posedge on lower, negedge on upper).
+ double lower_angle, upper_angle;
+ // The angles for decreasing values (negedge on lower, posedge on upper).
+ double lower_decreasing_angle, upper_decreasing_angle;
};
// The ratio from the encoder shaft to the drivetrain wheels.
@@ -72,6 +74,10 @@
double claw_min_separation;
double claw_max_separation;
+ // We should never get closer/farther than these.
+ double soft_min_separation;
+ double soft_max_separation;
+
// Three hall effects are known as front, calib and back
typedef Values::AnglePair AnglePair;