Skip to content

Commit 8c02aad

Browse files
author
Suhas
committed
dtyuidrthgfuhfjg
1 parent 4bad9ec commit 8c02aad

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

ut-robomaster/src/robots/hero/hero_constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ constexpr float CAMERA_X_OFFSET = 0.0f; // horizontal offset of main camera l
4444
constexpr float PITCH_MIN = -0.3349f; // rad
4545
constexpr float PITCH_MAX = 0.3534f; // rad
4646

47-
static constexpr float YAW_REDUCTION = 1.0f;
47+
static constexpr float YAW_REDUCTION = 2.005459491f;
4848
static constexpr float PITCH_REDUCTION = 1.0f;
4949

5050
// Tuning Constants -----------------------------------

ut-robomaster/src/subsystems/turret/double_yaw_motor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ void DoubleYawMotor::reset()
3434

3535
void DoubleYawMotor::updateMotorAngle()
3636
{
37-
float encoderAngle = static_cast<float>(motor1.getEncoder()->getPosition().getWrappedValue()) /
38-
DjiMotorEncoder::ENC_RESOLUTION / M3508.gearRatio / YAW_REDUCTION;
37+
float encoderAngle =
38+
static_cast<float>(motor1.getInternalEncoder().getEncoder().getUnwrappedValue()) /
39+
DjiMotorEncoder::ENC_RESOLUTION / M3508.gearRatio / YAW_REDUCTION;
3940
currentAngle.setWrappedValue(encoderAngle);
4041
}
4142

@@ -47,8 +48,8 @@ void DoubleYawMotor::setAngle(float desiredAngle, float dt)
4748
.minDifference(setpoint.getWrappedValue());
4849

4950
// account for chassis rotation
50-
float disturbance = drivers->bmi088.getGz() / 360.0f; // rev / s
51-
disturbance *= 2.0f; // seems to help?
51+
float disturbance = drivers->bmi088.getGz() / 2.0f / PI; // rev / s
52+
disturbance *= 2.0f; // seems to help?
5253

5354
float targetVelocity = positionPid.update(positionError, dt, false) - disturbance;
5455
setVelocity(targetVelocity, dt);

ut-robomaster/src/subsystems/turret/turret_motor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void TurretMotor::reset()
2828
void TurretMotor::updateMotorAngle()
2929
{
3030
// uint16_t encoderValue = motor.getEncoderWrapped();
31-
uint16_t encoderValue = motor.getEncoder()->getPosition().getWrappedValue();
31+
uint16_t encoderValue = motor.getInternalEncoder().getEncoder().getUnwrappedValue();
3232
if (lastUpdatedEncoderValue != encoderValue)
3333
{
3434
lastUpdatedEncoderValue = encoderValue;

ut-robomaster/src/subsystems/turret/turret_subsystem.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ void TurretSubsystem::initialize()
3232

3333
void TurretSubsystem::refresh()
3434
{
35-
// yaw.setOutput(0.5f);
36-
// pitch.motor.setDesiredOutput(M3508.maxOutput * 0.5);
37-
// who needs hardware checks?
38-
// setAmputated(!hardwareOk());
39-
40-
#if defined(TARGET_HERO)
41-
Remote* remote = &drivers->remote;
42-
float h = remote->getChannel(Remote::Channel::LEFT_HORIZONTAL);
43-
float v = remote->getChannel(Remote::Channel::LEFT_VERTICAL);
44-
yaw.setOutput(h);
45-
pitch.motor.setDesiredOutput(GM6020.maxOutput * v);
46-
return;
47-
#endif
48-
4935
yaw.updateMotorAngle();
5036
pitch.updateMotorAngle();
5137

@@ -54,7 +40,11 @@ void TurretSubsystem::refresh()
5440

5541
if (!isCalibrated && yawEncoder.isOnline())
5642
{
43+
#if defined(TARGET_HERO)
44+
baseYaw = -yaw.getAngle();
45+
#else
5746
baseYaw = yawEncoder.getAngle() - YAW_OFFSET - yaw.getAngle();
47+
#endif
5848
isCalibrated = true;
5949

6050
setTargetWorldAngles(getCurrentLocalYaw() + getChassisYaw(), getCurrentLocalPitch());
@@ -94,7 +84,7 @@ void TurretSubsystem::setTargetWorldAngles(float yaw, float pitch)
9484
targetWorldPitch = modm::min(modm::max(pitch, PITCH_MIN), PITCH_MAX);
9585
}
9686

97-
float TurretSubsystem::getChassisYaw() { return modm::toRadian(drivers->bmi088.getYaw()); }
87+
float TurretSubsystem::getChassisYaw() { return drivers->bmi088.getYaw(); }
9888

9989
float TurretSubsystem::getTargetLocalYaw() { return targetWorldYaw - getChassisYaw(); }
10090

ut-robomaster/src/utils/motors/motor_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ bool MotorController::isOnline() { return motor.isMotorOnline(); }
5050

5151
float MotorController::measurePosition()
5252
{
53-
int64_t encoderVal = motor.getEncoder()->getPosition().getUnwrappedValue();
53+
int64_t encoderVal = motor.getInternalEncoder().getEncoder().getUnwrappedValue();
5454
float units = static_cast<float>(encoderVal) / DjiMotorEncoder::ENC_RESOLUTION;
5555
float turns = units / constants.gearRatio; // revs
5656
return turns;

0 commit comments

Comments
 (0)