Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexDickhans committed Jul 26, 2022
1 parent 1721097 commit a05256c
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 39 deletions.
16 changes: 8 additions & 8 deletions include/odometry/continuousOdometry/mecanumOdometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ namespace Pronounce {

pros::Imu* imu;

double xOffset;
double yOffset;
QLength xOffset;
QLength yOffset;
public:
MecanumOdometry();
MecanumOdometry(double xOffset, double yOffset);
MecanumOdometry(OdomWheel* wheel1, OdomWheel* wheel2, OdomWheel* wheel3, OdomWheel* wheel4, pros::Imu* imu, double xOffset, double yOffset);
MecanumOdometry(QLength xOffset, QLength yOffset);
MecanumOdometry(OdomWheel* wheel1, OdomWheel* wheel2, OdomWheel* wheel3, OdomWheel* wheel4, pros::Imu* imu, QLength xOffset, QLength yOffset);

void update();

Expand All @@ -45,7 +45,7 @@ namespace Pronounce {
*
* @param xOffset
*/
void setXOffset(double xOffset) {
void setXOffset(QLength xOffset) {
this->xOffset = xOffset;
}

Expand All @@ -54,7 +54,7 @@ namespace Pronounce {
*
* @return double
*/
double getXOffset() {
QLength getXOffset() {
return xOffset;
}

Expand All @@ -63,7 +63,7 @@ namespace Pronounce {
*
* @param yOffset
*/
void setYOffset(double yOffset) {
void setYOffset(QLength yOffset) {
this->yOffset = yOffset;
}

Expand All @@ -72,7 +72,7 @@ namespace Pronounce {
*
* @return double
*/
double getYOffset() {
QLength getYOffset() {
return yOffset;
}

Expand Down
9 changes: 5 additions & 4 deletions include/position/avgOdom.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "odomWheel.hpp"
#include "units/units.hpp"
#include <vector>

namespace Pronounce {
Expand All @@ -22,8 +23,8 @@ namespace Pronounce {
/**
* Get the distance at the current moment
*/
double getPosition() {
double total = 0;
QLength getPosition() {
QLength total = 0.0;
for (int i = 0; i < odomWheels.size(); i++) {
total += odomWheels.at(i).getPosition();
}
Expand All @@ -38,8 +39,8 @@ namespace Pronounce {
}
}

double getChange() {
double total = 0;
QLength getChange() {
QLength total = 0.0;
for (int i = 0; i < odomWheels.size(); i++) {
total += odomWheels.at(i).getChange();
}
Expand Down
8 changes: 4 additions & 4 deletions include/position/odomWheel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Pronounce {
*/
class OdomWheel {
private:
QLength position = 0;
QLength lastPosition = 0;
QLength position = 0.0;
QLength lastPosition = 0.0;

QLength radius;

Expand All @@ -22,8 +22,8 @@ namespace Pronounce {
OdomWheel(double radius);

virtual void reset() {
position = 0;
lastPosition = 0;
position = 0.0;
lastPosition = 0.0;
}

QLength getRadius() {
Expand Down
2 changes: 1 addition & 1 deletion include/position/threeWireOdomWheel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Pronounce {
AdiOdomWheel(pros::ADIEncoder* encoder);

void update() {
this->setPosition((encoder->get_value()/360.0) * this->getRadius() * M_PI * 2.0 * this->getTuningFactor());
this->setPosition((encoder->get_value()/360.0) * this->getRadius().Convert(metre) * 1_pi * 2.0 * this->getTuningFactor());
}

void reset() {
Expand Down
2 changes: 1 addition & 1 deletion include/position/trackingWheel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Pronounce
}

void update() {
this->setPosition(((rotationSensor->get_position() / 100.0)/360.0) * this->getRadius() * M_PI * 2.0 * this->getTuningFactor());
this->setPosition(((rotationSensor->get_position() / 100.0)/360.0) * this->getRadius().getValue() * 1_pi * 2.0 * this->getTuningFactor());
}

~TrackingWheel();
Expand Down
14 changes: 7 additions & 7 deletions src/odometry/continuousOdometry/mecanumOdometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace Pronounce {
MecanumOdometry::MecanumOdometry(/* args */) {
}

MecanumOdometry::MecanumOdometry(double xOffset, double yOffset) {
MecanumOdometry::MecanumOdometry(QLength xOffset, QLength yOffset) {
this->xOffset = xOffset;
this->yOffset = yOffset;
}

MecanumOdometry::MecanumOdometry(OdomWheel* wheel1, OdomWheel* wheel2, OdomWheel* wheel3, OdomWheel* wheel4, pros::Imu* imu, double xOffset, double yOffset) : MecanumOdometry(xOffset, yOffset) {
MecanumOdometry::MecanumOdometry(OdomWheel* wheel1, OdomWheel* wheel2, OdomWheel* wheel3, OdomWheel* wheel4, pros::Imu* imu, QLength xOffset, QLength yOffset) : MecanumOdometry(xOffset, yOffset) {
this->wheel1 = wheel1;
this->wheel2 = wheel2;
this->wheel3 = wheel3;
Expand All @@ -31,10 +31,10 @@ namespace Pronounce {
Angle angleChange = 0.0;
Angle lastAngle = lastPose->getAngle();

double deltaWheel1 = wheel1->getChange();
double deltaWheel2 = wheel2->getChange();
double deltaWheel3 = wheel3->getChange();
double deltaWheel4 = wheel4->getChange();
QLength deltaWheel1 = wheel1->getChange();
QLength deltaWheel2 = wheel2->getChange();
QLength deltaWheel3 = wheel3->getChange();
QLength deltaWheel4 = wheel4->getChange();

if (useImu && imu != nullptr) {
if (imu->is_calibrating()) {
Expand All @@ -52,7 +52,7 @@ namespace Pronounce {
// Use the wheel encoders to determine orientation

// Calculate the orientation since last reset
Angle currentAngle = (-wheel1->getPosition() + wheel2->getPosition() - wheel3->getPosition() + wheel4->getPosition()) / (4 * xOffset, yOffset);
Angle currentAngle = (-wheel1->getPosition() + wheel2->getPosition() - wheel3->getPosition() + wheel4->getPosition()).getValue() / (4 * xOffset, yOffset).getValue();

angleChange = currentAngle - lastAngle;

Expand Down
16 changes: 8 additions & 8 deletions src/odometry/continuousOdometry/threeWheelOdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ namespace Pronounce {
backWheel->update();

// Get the current movement of odometry wheels
double deltaLeft = leftWheel->getChange();
double deltaRight = rightWheel->getChange();
double deltaBack = backWheel->getChange();
QLength deltaLeft = leftWheel->getChange();
QLength deltaRight = rightWheel->getChange();
QLength deltaBack = backWheel->getChange();

// Get the last robot position
Pose2D* lastPose = this->getPose();

// Calculate the change in orientation
Angle lastAngle = lastPose->getAngle();
Angle currentAngle = 0;
Angle currentAngle = 0.0;

if (useImu && imu != nullptr) {
currentAngle = toRadians(imu->get_rotation());
}
else {
currentAngle = this->getResetPose()->getAngle().getValue() + (leftWheel->getPosition() - rightWheel->getPosition()) / (leftOffset + rightOffset);
currentAngle = this->getResetPose()->getAngle().getValue() + (leftWheel->getPosition() - rightWheel->getPosition()).getValue() / (leftOffset + rightOffset).getValue();
}

Angle deltaAngle = (deltaLeft - deltaRight) / (leftOffset + rightOffset);
Angle deltaAngle = (deltaLeft - deltaRight).getValue() / (leftOffset + rightOffset).getValue();
Angle averageOrientation = lastAngle + (deltaAngle / 2);

Point localOffset;

if (deltaAngle.Convert(radian) != 0.0) {
double rotationAdjustment = 2 * sin(deltaAngle / 2);
localOffset = Point(((deltaBack/deltaAngle) + backOffset) * rotationAdjustment, ((deltaRight/deltaAngle) + rightOffset) * rotationAdjustment);
localOffset = Point(((deltaBack/deltaAngle).getValue() + backOffset.getValue()) * rotationAdjustment, ((deltaRight/deltaAngle).getValue() + rightOffset.getValue()) * rotationAdjustment);
} else {
// Calculate the local offset then translate it to the global offset
localOffset = Point(deltaBack, deltaRight);
Expand All @@ -66,7 +66,7 @@ namespace Pronounce {

// Add localOffset to the global offset
lastPose->add(localOffset);
lastPose->setAngle(fmod(angleDifference(currentAngle, 0) + M_PI * 2, M_PI * 2));
lastPose->setAngle(fmod(angleDifference(currentAngle.Convert(radian), 0) + M_PI * 2, M_PI * 2));

if (Vector(&localOffset).getMagnitude() > maxMovement && maxMovement.Convert(metre) != 0.0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/position/motorOdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Pronounce {
}

void MotorOdom::update() {
this->setPosition(motor->get_position() * this->getRadius() * M_PI * 2.0 * this->getTuningFactor());
this->setPosition(motor->get_position() * this->getRadius().Convert(metre) * 1_pi * 2.0 * this->getTuningFactor());
}
} // namespace Pronounce
4 changes: 2 additions & 2 deletions src/utils/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Pronounce {
Pose2D::Pose2D() : Point() {
this->angle = 0;
this->angle = 0.0;
}

Pose2D::Pose2D(double angle) : Point() {
this->angle = angle;
}

Pose2D::Pose2D(double x, double y) : Point(x, y) {
this->angle = 0;
this->angle = 0.0;
}

Pose2D::Pose2D(double x, double y, double angle) : Point(x, y) {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Pronounce {
Vector::Vector() {
this->magnitude = 0;
this->angle = 0;
this->magnitude = 0.0;
this->angle = 0.0;
}

Vector::Vector(QLength magnitude, Angle angle) {
Expand Down Expand Up @@ -55,7 +55,7 @@ namespace Pronounce {
Vector Vector::scale(double scalar) {
Vector vector = Vector(*this);

vector.setMagnitude(vector.getMagnitude() * scalar);
vector.setMagnitude(vector.getMagnitude().getValue() * scalar);

return vector;
}
Expand Down

0 comments on commit a05256c

Please sign in to comment.