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

Review TrajectoryLib #134

Closed
jgvictores opened this issue Jan 6, 2018 · 31 comments
Closed

Review TrajectoryLib #134

jgvictores opened this issue Jan 6, 2018 · 31 comments
Assignees
Labels

Comments

@jgvictores
Copy link
Member

Improve TrajectoryLib, starting by decoupling one and two limb trajectory generation.

Blocks #133, and more to come.

@jgvictores jgvictores added the blocking Focus on this issue before working on issues that are blocked by it label Jan 6, 2018
@jgvictores
Copy link
Member Author

Blocks #135 in addition to #133.

@jgvictores
Copy link
Member Author

jgvictores commented Jan 11, 2018

((comment omitted, DoF applies to joint space, here we are in Cartesian space))

@jgvictores
Copy link
Member Author

Note that several design decisions must be taken. We might have a meeting in person for this, I'll keep you informed.
cc: @PeterBowman @rsantos88

@jgvictores
Copy link
Member Author

@PeterBowman commented that he had started refractoring TrajectoryLib a while ago. Maybe some code or ideas hat we can reuse.

@jgvictores
Copy link
Member Author

imag4137

@jgvictores
Copy link
Member Author

Also blocks roboticslab-uc3m/teo-grasp#4

@jgvictores
Copy link
Member Author

@PeterBowman expressed concerns regarding being able to add several waypoints in a single function call.
@rsantos88 this is also useful for teo-grasp in relation to porting trajectories from openrave.

With https://github.com/roboticslab-uc3m/tools also in mind, I'm raising the bar and invoking some magic keywords:

serialization/deserialization

A.k.a. marshalling and unmarshalling.

@rsantos88
Copy link
Contributor

Just an idea, I think it would be interesting to make an example with the functional part of this library (in case it is usable) for example with LineTrajectory

@jgvictores
Copy link
Member Author

Just an idea, I think it would be interesting to make an example with the functional part of this library (in case it is usable) for example with LineTrajectory

Yes! Definitively. As a bare minimum, we should at least test the resulting class(es).

@jgvictores
Copy link
Member Author

Lots of progress (developed ITrajectoy, ICartesianTrajectoy, KdlTrajectory) at f02a0d8, actually improving BasicCartesianControl too (#135).

@jgvictores
Copy link
Member Author

Just an idea, I think it would be interesting to make an example with the functional part of this library (in case it is usable) for example with LineTrajectory

Added this test at 92a0c0b.

Still pending (but coming soon!): trajectories with paths other than ICartesianTrajectory::LINE.

@jgvictores
Copy link
Member Author

In addition to the test, there's also some pretty nice doxygen by now.

Next thoughts should be in the line of discrete trajectories, to address the use case of, say, wanting to retrieve the timestamp of the n-th waypoint.

@jgvictores
Copy link
Member Author

jgvictores commented Jan 20, 2018

Next thoughts should be in the line of discrete trajectories, to address the use case of, say, wanting to retrieve the timestamp of the n-th waypoint.

In addition to a potential (linear?) interpolation if requesting a movementTime from any of the methods that does not correspond precisely to a waypoint (and e.g. avoiding the interpolation if it does correspond.... within a certain tolerance xD).

@jgvictores
Copy link
Member Author

WIP at 6f3e7d8.

@jgvictores
Copy link
Member Author

Also blocks roboticslab-uc3m/teo-grasp#3

@jgvictores
Copy link
Member Author

jgvictores commented Dec 14, 2018

It turns out that libraries/YarpPlugins/AsibotSolver/TrajGen.hpp would be useful for the new libraries/TrajectoryLib/BasicJointTrajectory.hpp. @PeterBowman Maybe we could move things around (also rename a bit, something like OneJointTrajectory)?

@PeterBowman
Copy link
Member

PeterBowman commented Dec 14, 2018

TrajGen was kept for historical reasons, no code of ours is using that ATOW. If I'm correct, we even came close to removing it since KDL provides a similar functionality: KDL::VelocityProfile_Spline (supports up to 5th order splines, which we don't). Does it make sense to integrate/move TrajGen in the IJointTrajectory inheritance tree (even expand it so that initial/final accelerations are taken into account) and, if we ever need it, support velocity splines in the ICartesianTrajectory tree by means of the existing KdlTrajectory wrapper? Concerns: code duplication on one hand, avoiding unnecessary(/unrelated?) dependencies on the other hand.

@jgvictores
Copy link
Member Author

I'm not a big fan of adding dependencies, but even less a fan of code duplication. After reading your comment, this makes me inclined towards the use of KDL even for joint space trajectories. At time of writing KDL::VelocityProfile provides 5 different implementations that we may have ended up re-implementing (including the KDL::VelocityProfile_Spline you cite).

Looking at current issue-164-joint branch, maybe some renaming to be done?

  • KdlTrajectory -> KdlCartesianTrajectory
  • BasicJointTrajectory -> KdlJointTrajectory

@PeterBowman
Copy link
Member

KDL::VelocityProfile provides 5 different implementations that we may have ended up re-implementing

For the record, we already use KDL::VelocityProfile_Trap, and KDL::VelocityProfile_Rectangular is WIP for #166. But, there is no other re-implementation I know of apart from said TrajLib/KDL::DL::VelocityProfile_Spline. That one originated at asibot-main, probably before KDL was first used in RL code.

maybe some renaming to be done?

If KDL already has everything we need to implement IJointTrajectory, fine, then. I'll take care of edit conflicts across branches.

@jgvictores
Copy link
Member Author

That one originated at asibot-main, probably before KDL was first used in RL code.

TrajGen was intended to be a light-weight alternative to KDL with no additional dependencies. There was also a learn-by-doing motivation on my side. These reasons are IMHO historical and there is no strong motivation against using KDL even for joint space trajectories. It will actually allow Joint and Cartesian space trajectories to mutually benefit from any improvements/extensions in velocity profiles.

If KDL already has everything we need to implement IJointTrajectory, fine, then. I'll take care of edit conflicts across branches.

I'll give a try at using KDL in BasicJointTrajectory, I don't want to count my 🐔 before they hatch. If all goes well, I'll comment here and ask for your help for renaming while avoiding conflicts across branches.

@jgvictores
Copy link
Member Author

Slightly blocked, focusing on roboticslab-uc3m/teo-main#38 right now.

@PeterBowman
Copy link
Member

PeterBowman commented Jun 25, 2019

ASWJ we might consider dropping the ITrajectory wrapper class tree in favor of vanilla KDL's motion API.

@jgvictores jgvictores added the complexity: tedious Tedious task nobody wants to work on label Dec 21, 2019
@jgvictores
Copy link
Member Author

@PeterBowman
Copy link
Member

@jgvictores, let's ask the bold question: should we drop branch issue-164-joint (badly named, by the way) and turn this issue into "Nuke TrajectoryLib"? That is, use KDL directly instead of this thin wrapper of ours. I'm not quite proud of it and its pitfalls, had to code very carefully in the past and yet kept finding memory leaks. Extending this library (e.g. for rectangular velocity profiles) felt kinda useless as I could just call KDL methods instead.

@jgvictores
Copy link
Member Author

let's ask the bold question: should we drop branch issue-164-joint (badly named, by the way) and turn this issue into "Nuke TrajectoryLib"? That is, use KDL directly instead of this thin wrapper of ours. I'm not quite proud of it and its pitfalls, had to code very carefully in the past and yet kept finding memory leaks. Extending this library (e.g. for rectangular velocity profiles) felt kinda useless as I could just call KDL methods instead.

Yesssssssssssssssssss 👍

@PeterBowman PeterBowman changed the title Improve TrajectoryLib Review TrajectoryLib Mar 9, 2021
@PeterBowman
Copy link
Member

Tactical nuke dropped, there is no more TrajectoryLib at 692888d. Last stable implementation was available here. The issue-164-joint branch will be deleted, here is the full patchset for reference: a2bd56c...d266572.

Keep in mind the KDL motion API allows you not to configure certain parameters on construction, such as trajectory duration, maximum velocity, reference acceleration and so on. However, those must be accounted for anyway. A particular scenario involves trajectories with a starting point, a constant velocity and infinite duration (no end point):

if( duration == DURATION_NOT_SET )
{
if (velocityDrivenPath)
{
// assume we'll execute this trajectory indefinitely; since velocity
// depends on the path to travel along and the total duration, let's
// fix both to adjust the resulting velocity as requested by the user
double vel = path->PathLength(); // distance traveled during 1 time unit
double dummyGoal = 1e9; // somewhere far away
double dummyDuration = dummyGoal / vel;
velocityProfile->SetProfileDuration(0, dummyGoal, dummyDuration);
currentTrajectory = new KDL::Trajectory_Segment(path, velocityProfile);
}
else
{
velocityProfile->SetProfile(0, path->PathLength());
currentTrajectory = new KDL::Trajectory_Segment(path, velocityProfile);
}
}
else
{
if (velocityDrivenPath)
{
// execute the trajectory given an initial velocity and duration
double vel = path->PathLength(); // distance traveled during 1 time unit
double guessedGoal = vel * duration;
velocityProfile->SetProfileDuration(0, guessedGoal, duration);
currentTrajectory = new KDL::Trajectory_Segment(path, velocityProfile);
}
else
{
// velocity profile is set under the hood
currentTrajectory = new KDL::Trajectory_Segment(path, velocityProfile, duration);
}
}

SetProfileDuration can be used with a dummy waypoint which we know would never be reached, e.g. 10 meters away from start:

KDL::Path * path = new KDL::Path_Line(H, tw, new KDL::RotationalInterpolation_SingleAxis(), 1.0);
KDL::VelocityProfile * profile = new KDL::VelocityProfile_Rectangular(10.0);
profile->SetProfileDuration(0.0, 10.0, 10.0 / path->PathLength());
trajectory = new KDL::Trajectory_Segment(path, profile);
startTime = yarp::os::Time::now();

@PeterBowman PeterBowman unpinned this issue Mar 9, 2021
@jgvictores jgvictores removed the blocking Focus on this issue before working on issues that are blocked by it label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants