Skip to content

Commit

Permalink
Format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocky14683 committed Nov 27, 2023
1 parent b493d43 commit 4b2e331
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
4 changes: 3 additions & 1 deletion include/lemlib/logger/baseSink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class BaseSink {
*/
template <typename... T> void log(Level level, fmt::format_string<T...> format, T&&... args) {
if (!this->sinks.empty()) {
for (std::shared_ptr<BaseSink> sink : this->sinks) { sink->log(level, format, std::forward<T>(args)...); }
for (std::shared_ptr<BaseSink> sink : this->sinks) {
sink->log(level, format, std::forward<T>(args)...);
}
return;
}

Expand Down
2 changes: 1 addition & 1 deletion include/lemlib/odom/odom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Odom {
*
* @return Pose current pose
*/
Pose getPose()const;
Pose getPose() const;
/**
* @brief Set the current pose
*
Expand Down
4 changes: 3 additions & 1 deletion src/lemlib/devices/gyro/imu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ bool Imu::isCalibrating() const { return this->imu.is_calibrating(); }
*
* This function checks if the Imu is connected, is not calibrating,
*/
bool Imu::isCalibrated() { return this->isConnected() && !this->imu.is_calibrating() && !std::isinf(this->imu.get_heading()); }
bool Imu::isCalibrated() {
return this->isConnected() && !this->imu.is_calibrating() && !std::isinf(this->imu.get_heading());
}

/**
* return whether the IMU is installed
Expand Down
3 changes: 2 additions & 1 deletion src/lemlib/movements/boomerang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ std::pair<int, int> Boomerang::update(Pose pose) {
this->prevPose = pose;

// calculate the carrot point
Pose carrot = this->target - (Pose(cos(this->target.theta), sin(this->target.theta)) * this->lead * pose.distance(this->target));
Pose carrot = this->target -
(Pose(cos(this->target.theta), sin(this->target.theta)) * this->lead * pose.distance(this->target));
if (this->state == 1) carrot = this->target; // settling behavior

// calculate error
Expand Down
2 changes: 1 addition & 1 deletion src/lemlib/odom/odom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace lemlib {
/**
* Return current pose
*/
Pose Odom::getPose() const{ return this->pose; }
Pose Odom::getPose() const { return this->pose; }

/**
* Set current pose
Expand Down
12 changes: 8 additions & 4 deletions src/lemlib/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ bool FAPID::settled() {
} else { // check if the FAPID has settled
if (pros::c::millis() - this->startTime > this->maxTime) return true; // maxTime has been exceeded
if (std::fabs(this->prevError) < this->largeError) { // largeError within range
if (!this->largeTimeCounter) this->largeTimeCounter = pros::c::millis(); // largeTimeCounter has not been set
else if (pros::c::millis() - this->largeTimeCounter > this->largeTime) return true; // largeTime has been exceeded
if (!this->largeTimeCounter)
this->largeTimeCounter = pros::c::millis(); // largeTimeCounter has not been set
else if (pros::c::millis() - this->largeTimeCounter > this->largeTime)
return true; // largeTime has been exceeded
}
if (std::fabs(this->prevError) < this->smallError) { // smallError within range
if (!this->smallTimeCounter) this->smallTimeCounter = pros::c::millis(); // smallTimeCounter has not been set
else if (pros::c::millis() - this->smallTimeCounter > this->smallTime) return true; // smallTime has been exceeded
if (!this->smallTimeCounter)
this->smallTimeCounter = pros::c::millis(); // smallTimeCounter has not been set
else if (pros::c::millis() - this->smallTimeCounter > this->smallTime)
return true; // smallTime has been exceeded
}
// if none of the exit conditions have been met
return false;
Expand Down
12 changes: 9 additions & 3 deletions src/lemlib/pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ Pose Pose::operator/(const float& other) const { return Pose(this->x / other, th
* @param other the other pose
* @return bool
*/
bool Pose::operator==(const Pose& other) const { return this->x == other.x && this->y == other.y && this->theta == other.theta; }
bool Pose::operator==(const Pose& other) const {
return this->x == other.x && this->y == other.y && this->theta == other.theta;
}

/**
* @brief Check if two poses are not equal
*
* @param other the other pose
* @return bool
*/
bool Pose::operator!=(const Pose& other) const { return this->x != other.x || this->y != other.y || this->theta != other.theta; }
bool Pose::operator!=(const Pose& other) const {
return this->x != other.x || this->y != other.y || this->theta != other.theta;
}

/**
* @brief Linearly interpolate between two poses
Expand All @@ -114,7 +118,9 @@ bool Pose::operator!=(const Pose& other) const { return this->x != other.x || th
* @param t t value
* @return Pose
*/
Pose Pose::lerp(Pose other, float t) const { return Pose(this->x + (other.x - this->x) * t, this->y + (other.y - this->y) * t, this->theta); }
Pose Pose::lerp(Pose other, float t) const {
return Pose(this->x + (other.x - this->x) * t, this->y + (other.y - this->y) * t, this->theta);
}

/**
* @brief Get the distance between two poses
Expand Down
3 changes: 2 additions & 1 deletion src/lemlib/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace lemlib {
* makes the code more readable, and easier to develop.
*/
Timer::Timer(uint32_t time)
: period(time), lastTime(pros::millis()) {}
: period(time),
lastTime(pros::millis()) {}

/**
* Get the amount of time the timer is set to wait
Expand Down

0 comments on commit 4b2e331

Please sign in to comment.