Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FixedOrientation (Omni) and Sideward orientation modes #89

Merged
merged 7 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion global_planner/cfg/GlobalPlanner.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ orientation_enum = gen.enum([
"Negative y axis points along the path, except for the goal orientation"),
gen.const("Bidirectional", int_t, 7,
"Forward or backward depending on what requires less turning from start to path and from path to goal"),
gen.const("FixedOrientation", int_t, 8,
"Keep the same orientation as the orientation at the start pose, except at the goal"),
gen.const("Sideward", int_t, 9,
"Positive or negative y axis points along the path depending on what requires less turning from start to path and from path to goal"),
], "How to set the orientation of each point")

gen.add("orientation_mode", int_t, 0, "How to set the orientation of each point", 1, 0, 7,
gen.add("orientation_mode", int_t, 0, "How to set the orientation of each point", 1, 0, 9,
edit_method=orientation_enum)
gen.add("orientation_window_size", int_t, 0, "What window to use to determine the orientation based on the "
"position derivative specified by the orientation mode", 1, 1, 255)
Expand Down
2 changes: 1 addition & 1 deletion global_planner/include/global_planner/orientation_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

namespace global_planner {

enum OrientationMode { NONE, FORWARD, INTERPOLATE, FORWARDTHENINTERPOLATE, BACKWARD, LEFTWARD, RIGHTWARD, BIDIRECTIONAL };
enum OrientationMode { NONE, FORWARD, INTERPOLATE, FORWARDTHENINTERPOLATE, BACKWARD, LEFTWARD, RIGHTWARD, BIDIRECTIONAL, FIXEDORIENTATION, SIDEWARD };

class OrientationFilter {
public:
Expand Down
27 changes: 26 additions & 1 deletion global_planner/src/orientation_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ void OrientationFilter::processPath(const geometry_msgs::PoseStamped& start,
}
}
break;
case SIDEWARD:
for (int i = 0; i < n - 1; i++) {
setAngleBasedOnPositionDerivative(path, i);
}
if (n > 2) {
const int num_skips = n >= 5 ? 2 : 1;
const double rotation_to_path = min_angle(start, *std::next(path.begin(), num_skips));
const double rotation_to_goal = min_angle(*std::prev(path.end(), 1 + num_skips), path.back());
renan028 marked this conversation as resolved.
Show resolved Hide resolved

const bool prefer_leftward =
std::fabs(angles::normalize_angle(rotation_to_path - M_PI_2)) + std::fabs(angles::normalize_angle(rotation_to_goal + M_PI_2)) <
std::fabs(angles::normalize_angle(rotation_to_path + M_PI_2)) + std::fabs(angles::normalize_angle(rotation_to_goal - M_PI_2));

for (int i = 0; i < n - 1; i++) {
const double path_orientation = tf2::getYaw(path[i].pose.orientation);
const double adjusted_orientation = prefer_leftward ? path_orientation - M_PI_2 : path_orientation + M_PI_2;
set_angle(&path[i], angles::normalize_angle(adjusted_orientation));
}
}
break;
case LEFTWARD:
for(int i=0;i<n-1;i++){
setAngleBasedOnPositionDerivative(path, i);
Expand All @@ -109,6 +129,11 @@ void OrientationFilter::processPath(const geometry_msgs::PoseStamped& start,
set_angle(&path[i], angles::normalize_angle(tf2::getYaw(path[i].pose.orientation) + M_PI_2));
}
break;
case FIXEDORIENTATION:
for(int i=0;i<n-1;i++){
path[i].pose.orientation = start.pose.orientation;
}
break;
case INTERPOLATE:
path[0].pose.orientation = start.pose.orientation;
interpolate(path, 0, n-1);
Expand Down Expand Up @@ -161,6 +186,6 @@ void OrientationFilter::interpolate(std::vector<geometry_msgs::PoseStamped>& pat
set_angle(&path[i], angle);
}
}


};