Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

KD-tree attempt #494

Draft
wants to merge 28 commits into
base: dynamically-feasible-trajectories
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
90b2e5b
Fix histogram compression (#475)
baumanta Sep 2, 2019
1e18652
don't send range invalid range message
baumanta Sep 3, 2019
9fcb0ac
Port FSM to Local Planner (#472)
mrivi Sep 3, 2019
000650c
Plan dynamically feasible trajectories
Jul 22, 2019
65bcc6c
Fix style and tests
Jul 29, 2019
c04e945
Plan setpoints and positions separately
Jul 30, 2019
07589db
Stop A* at goal and fix setpoint visualization
Jul 30, 2019
32af0e4
Get rid of dynamic allocation when doing simulation and you only need…
jkflying Sep 3, 2019
ac9903f
Slightly cleaner trajectory simulator reusage
jkflying Sep 4, 2019
2327540
- add escape directions to the best candidate directio
mrivi Sep 15, 2019
18d0dd2
tmp
mrivi Sep 26, 2019
ae115b8
minor cleanup
mrivi Sep 27, 2019
84319ee
clang format
mrivi Sep 27, 2019
6a76096
Hack the histogram to get nearest distance in any direction from a po…
Jul 16, 2019
7a99f0a
KDTree: add getAllPoints() and size()
Sep 27, 2019
d14300b
KDTree: replace PCL cloud in planner
Sep 27, 2019
717f4dd
Fix style
Sep 27, 2019
e8a020a
star_planner: remove histogram
Sep 30, 2019
5c71530
star_planner: plan to goal
Sep 30, 2019
a486386
Fix style
Sep 30, 2019
6dc0c50
star_planner: use orientation to body-align setpoints
Sep 30, 2019
38a4521
star_planner: fix distance cost function
Sep 30, 2019
8766701
star_planner: exit search if outside sensor horizon
Sep 30, 2019
740fe1b
star_planner: move heuristic back to distance-based from time
Oct 1, 2019
7cb69c9
star_planner: only add nodes far enough from current nodes
Oct 1, 2019
ca41c59
star_planner: rename origin to current_node
Oct 1, 2019
10965dc
tree_node: rename origin to parent
Oct 1, 2019
f87509f
Use endpoints instead of whole trajectory
jkflying Oct 24, 2019
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
Prev Previous commit
Next Next commit
Slightly cleaner trajectory simulator reusage
jkflying authored and mrivi committed Sep 9, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ac9903fcb0a89c19afcf36c9bf2ea430c119cce4
4 changes: 2 additions & 2 deletions local_planner/include/local_planner/trajectory_simulator.h
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ class TrajectorySimulator {
const simulation_state& state);

private:
void generate_trajectory(const Eigen::Vector3f& goal_direction, int num_steps,
std::function<void(avoidance::simulation_state)> path_handler);
simulation_state generate_trajectory(const Eigen::Vector3f& goal_direction, int num_steps,
std::vector<simulation_state>* timepoints);
};

// templated helper function
24 changes: 10 additions & 14 deletions local_planner/src/utils/trajectory_simulator.cpp
Original file line number Diff line number Diff line change
@@ -23,11 +23,7 @@ TrajectorySimulator::TrajectorySimulator(const avoidance::simulation_limits& con
simulation_state TrajectorySimulator::generate_trajectory_endpoint(const Eigen::Vector3f& goal_direction,
float simulation_duration) {
int num_steps = static_cast<int>(std::ceil(simulation_duration / step_time_));
simulation_state last_state;

generate_trajectory(goal_direction, num_steps, [&last_state](simulation_state state) { last_state = state; });

return last_state;
return generate_trajectory(goal_direction, num_steps, nullptr);
}

std::vector<simulation_state> TrajectorySimulator::generate_trajectory(const Eigen::Vector3f& goal_direction,
@@ -36,22 +32,20 @@ std::vector<simulation_state> TrajectorySimulator::generate_trajectory(const Eig
std::vector<simulation_state> timepoints;
timepoints.reserve(num_steps);

generate_trajectory(goal_direction, num_steps,
[&timepoints](simulation_state state) { timepoints.push_back(state); });
generate_trajectory(goal_direction, num_steps, &timepoints);

return timepoints;
}

void TrajectorySimulator::generate_trajectory(const Eigen::Vector3f& goal_direction, int num_steps,
std::function<void(avoidance::simulation_state)> path_handler) {
simulation_state TrajectorySimulator::generate_trajectory(const Eigen::Vector3f& goal_direction, int num_steps,
std::vector<simulation_state>* timepoints) {
const Eigen::Vector3f unit_goal = goal_direction.normalized();
const Eigen::Vector3f desired_velocity =
xy_norm_z_clamp(unit_goal * std::hypot(config_.max_xy_velocity_norm,
unit_goal.z() > 0 ? config_.max_z_velocity : config_.min_z_velocity),
config_.max_xy_velocity_norm, config_.min_z_velocity, config_.max_z_velocity);

// calculate P and D constants such that they hit the jerk limit when
// doing accel from 0
// calculate P and D constants such that they hit the jerk limit when doing accel from 0
float max_accel_norm = std::min(2 * std::sqrt(config_.max_jerk_norm), config_.max_acceleration_norm);
float P_constant =
(std::sqrt(sqr(max_accel_norm) + config_.max_jerk_norm * desired_velocity.norm()) - max_accel_norm) /
@@ -64,8 +58,7 @@ void TrajectorySimulator::generate_trajectory(const Eigen::Vector3f& goal_direct
const Eigen::Vector3f damped_jerk =
jerk_for_velocity_setpoint(P_constant, D_constant, config_.max_jerk_norm, desired_velocity, run_state);

// limit time step to not exceed the maximum acceleration, but clamp
// jerk to 0 if at maximum acceleration already
// limit time step to not exceed the maximum acceleration, but clamp jerk to 0 if at maximum acceleration already
const Eigen::Vector3f requested_accel = run_state.acceleration + single_step_time * damped_jerk;
Eigen::Vector3f jerk = damped_jerk;
if (requested_accel.squaredNorm() > sqr(max_accel_norm)) {
@@ -79,8 +72,11 @@ void TrajectorySimulator::generate_trajectory(const Eigen::Vector3f& goal_direct

// update the state based on motion equations with the final jerk
run_state = simulate_step_constant_jerk(run_state, jerk, single_step_time);
path_handler(run_state);
if (timepoints != nullptr) {
timepoints->push_back(run_state);
}
}
return run_state;
}

simulation_state TrajectorySimulator::simulate_step_constant_jerk(const simulation_state& state,