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

Feature/concatenate trajs #354

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

rachelholladay
Copy link
Member

Util functionality to concatenate a list of trajectories into one trajectory by appending them onto each other.

Requested by @gilwoolee

@@ -2129,3 +2129,50 @@ def GetPointFrom(focus):
raise ValueError('Focus of the point is an unknown object')

return coord

def concatenateTrajectories(traj_list):
Copy link
Member

Choose a reason for hiding this comment

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

We follow OpenRAVE's naming convention by using PascalCase instead of camelCase.

@mkoval
Copy link
Member

mkoval commented Sep 11, 2016

I posted a few comments. The implementation should actually become quite a bit simpler after applying those changes.

@rachelholladay: Could you take a look?

@rachelholladay
Copy link
Member Author

@mkoval I made the changes you requested. The problem I notice (which I didn't before) is that this doesn't check the flags of the first trajectory in the list. The two ways I thought to fix this were

  1. Create a function that checks flags and call it on the first trajectory separately (and in the loop).
  2. Change the loop to iterate through all trajectories, but initialize base_traj to be a blank trajectory instead of the first one in the list.

Would one be preferred over the other? Or some other option I haven't considered?

deterministcTrajectoryFlag = False

# True if the last trajectory has this set
if i == len(traj_list)-1 and 'deterministic_endpoint' in tags_i and tags_i['determinstic_endpoint']:
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be cleaner to do this outside of the loop?

@gilwoolee
Copy link
Contributor

@rachelholladay Thanks for this PR! This concatenation can be further postprocessed to smoothen and shortcut a sequence of trajectories, which would be useful addition. As for the question you asked, I think option 2 (initializing with an empty base trajectory) would be cleaner.

@rachelholladay
Copy link
Member Author

@gilwoolee I switched it to using a blank trajectory and even added a unit test. I guess I'd like to have a function argument for whether it should be smoothed or not. What do you think?

Copy link
Contributor

@gilwoolee gilwoolee left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Left some comments and questions.


# Create an empty trajectory to populate
base_traj = openravepy.RaveCreateTrajectory(env, '')
base_cspec = robot.GetActiveConfigurationSpecification('linear')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this to be linear? Also, why are we requiring that the trajectories have to be on the current active dofs? Shouldn't it just be the spec of the first trajectory?

base_traj = openravepy.RaveCreateTrajectory(env, '')
base_cspec = robot.GetActiveConfigurationSpecification('linear')
base_traj.Init(base_cspec)
#base_cspec = base_traj.GetConfigurationSpecification()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this.

tags = GetTrajectoryTags(traj)
# Only True if all trajectories have this set
if 'smooth' in tags and not tags['smooth']:
smoothFlag = False
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be skipped if smooth is not in tags. Is smooth by default true?

constrainedFlag = True

# Only True if all trajectories have this set
if 'deterministic' in tags and not tags['deterministic']:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question.

base_traj.Insert(offset, traj.GetWaypoint(0))
offset += 1
else:
if sum(numpy.subtract(traj.GetWaypoint(0), base_traj.GetWaypoint(offset-1))) > epsilon:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use numpy.linalg.norm here.

decimal=4,
err_msg=error,
verbose=True)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests for checking tags? E.g. when one of the tags along the trajectory is not smooth, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants