Skip to content

Commit

Permalink
Fix Code Style On intermediate-pathgen (#2269)
Browse files Browse the repository at this point in the history
automated style fixes

Co-authored-by: sid-parikh <sid-parikh@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and sid-parikh authored Sep 29, 2024
1 parent e4fd024 commit 463dcce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
20 changes: 12 additions & 8 deletions soccer/src/soccer/planning/planning_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ DEFINE_NS_INT64(kPlanningParamModule, rrt, min_iterations, 50,
DEFINE_NS_INT64(kPlanningParamModule, rrt, max_iterations, 500,
"Maximum number of RRT iterations to run before giving up");


DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, min_scale, 0.5, "Minimum length for intermediate point (m)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, max_scale, 1.5, "Maximum length for intermediate point (m)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, min_angle, 20, "Minimum angle for intermediate point (deg)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, max_angle, 140, "Maximum angle for intermediate point (deg)");
DEFINE_NS_INT64(kPlanningParamModule, intermediate, num_intermediates, 5, "Number of intermediate points used (unitless)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, step_size, 0.1, "Step size for testing intermediates (m)");

DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, min_scale, 0.5,
"Minimum length for intermediate point (m)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, max_scale, 1.5,
"Maximum length for intermediate point (m)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, min_angle, 20,
"Minimum angle for intermediate point (deg)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, max_angle, 140,
"Maximum angle for intermediate point (deg)");
DEFINE_NS_INT64(kPlanningParamModule, intermediate, num_intermediates, 5,
"Number of intermediate points used (unitless)");
DEFINE_NS_FLOAT64(kPlanningParamModule, intermediate, step_size, 0.1,
"Step size for testing intermediates (m)");

DEFINE_NS_FLOAT64(
kPlanningParamModule, escape, step_size, 0.1,
Expand Down
10 changes: 6 additions & 4 deletions soccer/src/soccer/planning/primitives/create_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Trajectory rrt(const LinearMotionInstant& start, const LinearMotionInstant& goal

static std::optional<std::tuple<double, double, double>> cached_intermediate_tuple_{};


Trajectory intermediate(const LinearMotionInstant& start, const LinearMotionInstant& goal,
const MotionConstraints& motion_constraints, RJ::Time start_time,
const rj_geometry::ShapeSet& static_obstacles) {
Expand Down Expand Up @@ -105,7 +104,8 @@ Trajectory intermediate(const LinearMotionInstant& start, const LinearMotionInst

// Step through the path from the robot to the final intermediate point
// and test each point on that path as an intermediate point
for (double t = intermediate::PARAM_step_size; t < final_inter.dist_to(start.position); t += intermediate::PARAM_step_size) {
for (double t = intermediate::PARAM_step_size; t < final_inter.dist_to(start.position);
t += intermediate::PARAM_step_size) {
rj_geometry::Point intermediate =
(final_inter - start.position).normalized(t) + start.position;
Trajectory trajectory =
Expand All @@ -114,7 +114,8 @@ Trajectory intermediate(const LinearMotionInstant& start, const LinearMotionInst
// If the trajectory does not hit an obstacle, it is valid
if ((!trajectory_hits_static(trajectory, static_obstacles, start_time, nullptr))) {
auto angle = (final_inter - start.position).angle();
cached_intermediate_tuple_ = {abs(angle), signbit(angle) ? -1 : 1, (final_inter - start.position).mag()};
cached_intermediate_tuple_ = {abs(angle), signbit(angle) ? -1 : 1,
(final_inter - start.position).mag()};
return trajectory;
}
}
Expand All @@ -130,7 +131,8 @@ std::vector<rj_geometry::Point> get_intermediates(const LinearMotionInstant& sta
std::mt19937 gen(rd());
// Create a random distribution for the distance between the start
// and the intermediate points
std::uniform_real_distribution<> scale_dist(intermediate::PARAM_min_scale, intermediate::PARAM_max_scale);
std::uniform_real_distribution<> scale_dist(intermediate::PARAM_min_scale,
intermediate::PARAM_max_scale);

double angle_range = intermediate::PARAM_max_angle - intermediate::PARAM_min_angle;
// Create a random distribution for the angle between the start
Expand Down
3 changes: 2 additions & 1 deletion soccer/src/soccer/planning/primitives/create_path.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <random>
#include <optional>
#include <random>

#include "planning/motion_constraints.hpp"
#include "planning/primitives/path_smoothing.hpp"
#include "planning/trajectory.hpp"
Expand Down

0 comments on commit 463dcce

Please sign in to comment.