Created
September 10, 2018 13:02
-
-
Save rpapallas/84613c6f0c44aa892f8c265f5b87153b to your computer and use it in GitHub Desktop.
OMPL to OpenRAVE Trajectory with custom delta times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input: | |
// path: ompl::control::PathControl | |
// penv: OpenRAVE::EnvironmentBasePtr | |
// robot: OpenRAVE::RobotBasePtr | |
// | |
// Output: Will create an OpenRAVE trajectory from the OMPL PathControl and will also parse deltatimes. | |
TrajectoryBasePtr or_traj = RaveCreateTrajectory(penv, ""); | |
auto configuration_specification = robot->GetActiveConfigurationSpecification(); | |
configuration_specification.AddDeltaTimeGroup(); | |
or_traj->Init(configuration_specification); | |
double deltaTime = 0.0; | |
for (size_t i = 0; i < path.getStateCount(); ++i) { | |
std::vector<double> values; | |
stateSpace->copyToReals(values, path.getState(i)); | |
if( i > 0 ) { | |
double controlDuration = path.getControlDuration(i); | |
deltaTime = deltaTime + controlDuration; | |
} | |
values.push_back(deltaTime); | |
or_traj->Insert(i, values, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment