Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
jazonshou committed Nov 8, 2024
1 parent 1c250c7 commit 628be02
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/TunePID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extern "C" {
}

enum class targetmode_t {
step, sinusoidal
step,
sinusoidal
};

using namespace robot::types;
Expand Down Expand Up @@ -145,7 +146,8 @@ int main(int argc, char** argv) {

time_point<steady_clock> tp = steady_clock::now();
time_point<steady_clock> startTime = tp;
while (steady_clock::now() - startTime < 3 * milliseconds(static_cast<int>(period * 1000))) {
while (steady_clock::now() - startTime <
3 * milliseconds(static_cast<int>(period * 1000))) {
int32_t current_angle = can::motor::getMotorPosition(serial).getData();
double difference = (current_angle - angle_target) / 1000.0;
acc_error += difference * difference;
Expand All @@ -159,7 +161,7 @@ int main(int argc, char** argv) {
if (mode == targetmode_t::step) {
prescaled_target = round(prescaled_target);
}
angle_target = (int32_t) round(amplitude * prescaled_target) + starting_angle;
angle_target = (int32_t)round(amplitude * prescaled_target) + starting_angle;

can::motor::setMotorPIDTarget(serial, angle_target);

Expand Down
3 changes: 2 additions & 1 deletion src/ar/ARTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ std::vector<cv::Point2d> projectCube(float len, cv::Vec3d rvec, cv::Vec3d tvec)
}

std::vector<cv::Point2f> projectGrid(cv::Size imageSize, int spacing) {
cv::Point2f center(static_cast<float>(imageSize.width) / 2.0f, static_cast<float>(imageSize.height) / 2.0f);
cv::Point2f center(static_cast<float>(imageSize.width) / 2.0f,
static_cast<float>(imageSize.height) / 2.0f);
std::vector<cv::Point2f> grid_points;
std::vector<cv::Point2f> projected_points;
float xf, yf;
Expand Down
24 changes: 17 additions & 7 deletions src/camera/calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,16 @@ static void help(char** argv) {
printf("\n%s", liveCaptureHelp);
}

enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 };
enum Pattern { CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };
enum {
DETECTION = 0,
CAPTURING = 1,
CALIBRATED = 2
};
enum Pattern {
CHESSBOARD,
CIRCLES_GRID,
ASYMMETRIC_CIRCLES_GRID
};

static double
computeReprojectionErrors(const std::vector<std::vector<cv::Point3f>>& objectPoints,
Expand Down Expand Up @@ -310,7 +318,8 @@ saveCameraParams(const std::string& filename, cv::Size imageSize, cv::Size board
}

if (!imagePoints.empty()) {
cv::Mat imagePtMat(static_cast<int>(imagePoints.size()), static_cast<int>(imagePoints[0].size()), CV_32FC2);
cv::Mat imagePtMat(static_cast<int>(imagePoints.size()),
static_cast<int>(imagePoints[0].size()), CV_32FC2);
for (int i = 0; i < static_cast<int>(imagePoints.size()); i++) {
cv::Mat r = imagePtMat.row(i).reshape(2, imagePtMat.cols);
cv::Mat imgpti(imagePoints[i]);
Expand Down Expand Up @@ -563,17 +572,18 @@ int main(int argc, char** argv) {
if (found)
drawChessboardCorners(view, boardSize, cv::Mat(pointbuf), found);

std::string msg = mode == CAPTURING
? "100/100"
: mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";
std::string msg = mode == CAPTURING ? "100/100"
: mode == CALIBRATED ? "Calibrated"
: "Press 'g' to start";
int baseLine = 0;
cv::Size textSize = cv::getTextSize(msg, 1, 1, 1, &baseLine);
cv::Point textOrigin(view.cols - 2 * textSize.width - 10,
view.rows - 2 * baseLine - 10);

if (mode == CAPTURING) {
if (undistortImage)
msg = cv::format("%d/%d Undist", static_cast<int>(imagePoints.size()), nframes);
msg =
cv::format("%d/%d Undist", static_cast<int>(imagePoints.size()), nframes);
else
msg = cv::format("%d/%d", static_cast<int>(imagePoints.size()), nframes);
}
Expand Down

0 comments on commit 628be02

Please sign in to comment.