Skip to content

Commit

Permalink
minor code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
pantor committed Oct 11, 2021
1 parent edfa66d commit d74e394
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

Ruckig generates trajectories on-the-fly, allowing robots and machines to react instantaneously to sensor input. Ruckig calculates a trajectory to a *target* waypoint (with position, velocity, and acceleration) starting from *any* initial state limited by velocity, acceleration, and jerk constraints. Besides the target state, the Ruckig *Pro Version* allows to define intermediate positions for waypoint following. For state-to-state motions, Ruckig guarantees a time-optimal solution. With intermediate waypoints, Ruckig calculates the path and its time parametrization jointly, resulting in significantly faster trajectories compared to traditional methods. The Ruckig *Community Version* is a more powerful and open-source alternative to the [Reflexxes Type IV](http://reflexxes.ws/) library. In fact, Ruckig is the first Type V trajectory generator for arbitrary target states and even supports directional velocity and acceleration limits, while also being faster on top.

More information can be found in the corresponding paper [Jerk-limited Real-time Trajectory Generation with Arbitrary Target States](https://arxiv.org/abs/2105.04830), accepted for the *Robotics: Science and Systems (RSS), 2021* conference.
More information can be found at [ruckig.com](https://ruckig.com) and in the corresponding paper [Jerk-limited Real-time Trajectory Generation with Arbitrary Target States](https://arxiv.org/abs/2105.04830), accepted for the *Robotics: Science and Systems (RSS), 2021* conference.


## Installation
Expand Down
20 changes: 10 additions & 10 deletions include/ruckig/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Block {
}

if constexpr (numerical_robust) {
size_t idx_min = (valid_profiles[0].t_sum[6] < valid_profiles[1].t_sum[6]) ? 0 : 1;
size_t idx_else_1 = (idx_min + 1) % 2;
const size_t idx_min = (valid_profiles[0].t_sum[6] < valid_profiles[1].t_sum[6]) ? 0 : 1;
const size_t idx_else_1 = (idx_min + 1) % 2;

block = Block(valid_profiles[idx_min]);
Block::add_interval(block.a, valid_profiles[idx_min], valid_profiles[idx_else_1]);
Expand All @@ -92,23 +92,23 @@ class Block {
}

// Find index of fastest profile
auto idx_min_it = std::min_element(valid_profiles.cbegin(), valid_profiles.cbegin() + valid_profile_counter, [](const Profile& a, const Profile& b) { return a.t_sum[6] + a.t_brake.value_or(0.0) < b.t_sum[6] + b.t_brake.value_or(0.0); });
size_t idx_min = std::distance(valid_profiles.cbegin(), idx_min_it);
const auto idx_min_it = std::min_element(valid_profiles.cbegin(), valid_profiles.cbegin() + valid_profile_counter, [](const Profile& a, const Profile& b) { return a.t_sum[6] < b.t_sum[6]; });
const size_t idx_min = std::distance(valid_profiles.cbegin(), idx_min_it);

block = Block(valid_profiles[idx_min]);

if (valid_profile_counter == 3) {
size_t idx_else_1 = (idx_min + 1) % 3;
size_t idx_else_2 = (idx_min + 2) % 3;
const size_t idx_else_1 = (idx_min + 1) % 3;
const size_t idx_else_2 = (idx_min + 2) % 3;

Block::add_interval(block.a, valid_profiles[idx_else_1], valid_profiles[idx_else_2]);
return true;

} else if (valid_profile_counter == 5) {
size_t idx_else_1 = (idx_min + 1) % 5;
size_t idx_else_2 = (idx_min + 2) % 5;
size_t idx_else_3 = (idx_min + 3) % 5;
size_t idx_else_4 = (idx_min + 4) % 5;
const size_t idx_else_1 = (idx_min + 1) % 5;
const size_t idx_else_2 = (idx_min + 2) % 5;
const size_t idx_else_3 = (idx_min + 3) % 5;
const size_t idx_else_4 = (idx_min + 4) % 5;

if (valid_profiles[idx_else_1].direction == valid_profiles[idx_else_2].direction) {
Block::add_interval(block.a, valid_profiles[idx_else_1], valid_profiles[idx_else_2]);
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def build_extension(self, ext):
long_description=long_description,
long_description_content_type='text/markdown',
author='Lars Berscheid',
author_email='lars.berscheid@kit.edu',
url='https://github.com/pantor/ruckig',
author_email='info@ruckig.com',
url='https://www.ruckig.com',
packages=find_packages(),
license='MIT',
ext_modules=[CMakeExtension('python_ruckig')],
Expand Down
16 changes: 6 additions & 10 deletions src/position-step1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void PositionStep1::time_all_vel(Profile& profile, double vMax, double vMin, dou
}

// ACC1_VEL
const double t_acc0 = Sqrt(a0_a0/(2*jMax_jMax) + (vMax - v0)/jMax);
const double t_acc0 = std::sqrt(a0_a0/(2*jMax_jMax) + (vMax - v0)/jMax);

profile.t[0] = t_acc0 - a0/jMax;
profile.t[1] = 0;
Expand All @@ -54,7 +54,7 @@ void PositionStep1::time_all_vel(Profile& profile, double vMax, double vMin, dou
}

// ACC0_VEL
const double t_acc1 = Sqrt(af_af/(2*jMax_jMax) + (vMax - vf)/jMax);
const double t_acc1 = std::sqrt(af_af/(2*jMax_jMax) + (vMax - vf)/jMax);

profile.t[0] = (-a0 + aMax)/jMax;
profile.t[1] = (a0_a0/2 - aMax*aMax - jMax*(v0 - vMax))/(aMax*jMax);
Expand Down Expand Up @@ -130,8 +130,7 @@ void PositionStep1::time_acc1(Profile& profile, double vMax, double vMin, double

// double h4 = a0_a0/(aMin*aMin) + h3*jMax/aMin;
// if (a0*aMin > 0 && h4 > 0) {
// h4 = Sqrt(h4);
// if (t_max < -(a0 - aMin*h4)/jMax) {
// if (t_max < -(a0 - aMin*std::sqrt(h4))/jMax) {
// return;
// }
// }
Expand Down Expand Up @@ -186,15 +185,12 @@ void PositionStep1::time_acc1(Profile& profile, double vMax, double vMin, double

void PositionStep1::time_acc0(Profile& profile, double vMax, double vMin, double aMax, double aMin, double jMax) {
const double h3 = (a0_a0 - af_af)/(2*aMax*jMax) + (vf - v0)/aMax;
const double t_max = (aMax - aMin)/jMax;

// if (h3 < 0) {
// const double h4 = Sqrt(1 - h3 * jMax/aMax);
// if (t_max < (1 + h4)/(jMax/aMax) - DBL_EPSILON) {
// return;
// }
// if (h3 < (aMax*aMax - aMin*aMin)/(jMax*aMax)) {
// return;
// }

const double t_max = (aMax - aMin)/jMax;
const double h0 = 3*(af_p4 - a0_p4) + 8*(a0_p3 - af_p3)*aMax + 24*aMax*jMax*(af*vf - a0*v0) - 6*a0_a0*(aMax*aMax - 2*jMax*v0) + 6*af_af*(aMax*aMax - 2*jMax*vf) + 12*jMax*(jMax*(vf_vf - v0_v0 - 2*aMax*pd) - aMax*aMax*(vf - v0));
const double h2 = -af_af + aMax*aMax + 2*jMax*vf;

Expand Down

0 comments on commit d74e394

Please sign in to comment.