Skip to content

Commit

Permalink
Added possibility to modify the start position from external sources,…
Browse files Browse the repository at this point in the history
… as its done in the _getMaxXYSpeed
  • Loading branch information
Claudio-Chies committed Nov 29, 2024
1 parent 42d169e commit b696c45
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/motion_planning/PositionSmoothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,17 @@ float PositionSmoothing::_getMaxXYSpeed(const Vector3f(&waypoints)[3]) const

float PositionSmoothing::_getMaxZSpeed(const Vector3f(&waypoints)[3]) const
{
const Vector3f &start_position = waypoints[0];
const Vector3f &start_position = {_trajectory[0].getCurrentPosition(),
_trajectory[1].getCurrentPosition(),
_trajectory[2].getCurrentPosition()
};
const Vector3f &target = waypoints[1];
const Vector3f &next_target = waypoints[2];

const Vector2f start_position_xy_z = {start_position.xy().norm(), start_position(2)};
const Vector2f target_xy_z = {target.xy().norm(), target(2)};
const Vector2f next_target_xy_z = {next_target.xy().norm(), next_target(2)};

Vector3f pos_traj(_trajectory[0].getCurrentPosition(),
_trajectory[1].getCurrentPosition(),
_trajectory[2].getCurrentPosition());

float arrival_z_speed = 0.0f;
const bool target_next_different = fabsf(target(2) - next_target(2)) > 0.001f;

Expand All @@ -132,7 +131,7 @@ float PositionSmoothing::_getMaxZSpeed(const Vector3f(&waypoints)[3]) const
arrival_z_speed = math::min(max_speed_in_turn, _trajectory[2].getMaxVel());
}

const float distance_start_target = fabs(target(2) - pos_traj(2));
const float distance_start_target = fabs(target(2) - start_position(2));
float max_speed = math::min(_trajectory[2].getMaxVel(), math::trajectory::computeMaxSpeedFromDistance(
_trajectory[2].getMaxJerk(), _trajectory[2].getMaxAccel(),
distance_start_target, arrival_z_speed));
Expand Down

0 comments on commit b696c45

Please sign in to comment.