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

Changed spline interpolation to use the last commanded joint velocity… #195

Merged
merged 9 commits into from
Mar 20, 2024

Conversation

urmahp
Copy link
Collaborator

@urmahp urmahp commented Feb 21, 2024

… when calculating the next spline in the trajectory

Also limited the acceleration to the maximum joint acceleration of the target accelerations calculated from the spline. But still added a constant acceleration when slowing down is active, as the acceleration in the trajectory no longer can be used.

This will fix the issue with discontinuous motion when speed scaling is active

This will fix issue #194

… when calculating the next spline in the trajectory

Also limited the acceleration to the maximum joint acceleration of the target accelerations calculated from the spline. But still added a constant acceleration when slowing down is active, as the acceleration in the trajectory no longer can be used.

This will fix the issue with discontinuous motion when speed scaling is active
@urmahp urmahp requested a review from urrsk February 21, 2024 14:21
Copy link
Member

@urrsk urrsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Lets take it through an extra iterations and fix the test as well

end

# search for maximum
local i = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve efficiency

Suggested change
local i = 0
local i = 1

# ensure we have something to iterate over
local length = get_list_length(list)
if length == 0:
popup("Getting the maximum of an empty list is impossible in list_max().", error = True, blocking = True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that this is the best way to handle the case of receiving an empty list.
Maybe ignore the trajectory instead (with an error message) and let the driver continue to be ready to receive the next command.

def jointSplineStep(coefficients1, coefficients2, coefficients3, coefficients4, coefficients5, splineTimerTraveled, timestep, scaling_factor):
local qd = coefficients1 + 2.0 * splineTimerTraveled * coefficients2 + 3.0 * pow(splineTimerTraveled, 2) * coefficients3 + 4.0 * pow(splineTimerTraveled, 3) * coefficients4 + 5.0 * pow(splineTimerTraveled, 4) * coefficients5
def jointSplineStep(coefficients1, coefficients2, coefficients3, coefficients4, coefficients5, splineTimerTraveled, timestep, scaling_factor, is_slowing_down=False):
last_spline_qd = coefficients1 + 2.0 * splineTimerTraveled * coefficients2 + 3.0 * pow(splineTimerTraveled, 2) * coefficients3 + 4.0 * pow(splineTimerTraveled, 3) * coefficients4 + 5.0 * pow(splineTimerTraveled, 4) * coefficients5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to find a better name, as it only is the last_spline_qd next time!


if is_slowing_down:
last_spline_qd = last_spline_qd * scaling_factor
speedj(last_spline_qd, 15.0, timestep)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid hardcoded duplicates constants. Use a variable instead

last_spline_qd = last_spline_qd * scaling_factor
speedj(last_spline_qd, 15.0, timestep)
else:
max_qdd = list_max_norm(last_spline_qdd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest that we calculate the qdd argument for speedj more simple way; by substracting the last qd with the current calculated qd.
In practice it will not have any impact as we are doing it in very small intervals/steps

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.09%. Comparing base (4997115) to head (e6e12bd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #195   +/-   ##
=======================================
  Coverage   72.09%   72.09%           
=======================================
  Files          71       71           
  Lines        2652     2652           
  Branches      337      337           
=======================================
  Hits         1912     1912           
  Misses        554      554           
  Partials      186      186           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator Author

@urmahp urmahp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good and I am fine with merging this.

tests/test_spline_interpolation.cpp Outdated Show resolved Hide resolved
// Acceleration should only increase or be constant within one scaled timescale.
// It should not fluctuate to zero or overshoot
EXPECT_EQ(sign(last_change_acc[i]), sign(change_acc[i]))
<< " acceleration change direction doing "
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a debug message wasn't fully deleted here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended. The debug message is only printed out if the EXPECT_EQ fails.

Co-authored-by: Mads Holm Peters <79145214+urmahp@users.noreply.github.com>
// Acceleration should only increase or be constant within one scaled timescale.
// It should not fluctuate to zero or overshoot
EXPECT_EQ(sign(last_change_acc[i]), sign(change_acc[i]))
<< " acceleration change direction doing "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended. The debug message is only printed out if the EXPECT_EQ fails.

@urrsk urrsk merged commit d21a402 into UniversalRobots:master Mar 20, 2024
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants