Skip to content

Commit bd4552d

Browse files
Update online planning example and toJointTrajectory to leverage trajectory uuid
1 parent 183e3be commit bd4552d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tesseract_command_language/src/utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ tesseract_common::JointTrajectory toJointTrajectory(const CompositeInstruction&
6363
std::vector<std::reference_wrapper<const InstructionPoly>> flattened_program =
6464
composite_instructions.flatten(toJointTrajectoryInstructionFilter);
6565
trajectory.reserve(flattened_program.size());
66+
trajectory.uuid = composite_instructions.getUUID();
6667
trajectory.description = composite_instructions.getDescription();
6768

6869
double last_time = 0;

tesseract_examples/include/tesseract_examples/online_planning_example.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3737
#include <string>
3838
#include <Eigen/Geometry>
39+
#include <boost/uuid/uuid.hpp>
3940
#include <trajopt_sqp/fwd.h>
4041
#include <trajopt_ifopt/fwd.h>
4142
#include <tesseract_common/eigen_types.h>
@@ -107,6 +108,7 @@ class OnlinePlanningExample : public Example
107108

108109
std::shared_ptr<const tesseract_kinematics::KinematicGroup> manip_;
109110
tesseract_visualization::TrajectoryPlayer player_;
111+
boost::uuids::uuid current_trajectory_uuid_{};
110112
tesseract_common::TrajArray current_trajectory_;
111113
Eigen::Isometry3d target_pose_delta_;
112114
Eigen::Isometry3d target_pose_base_frame_;

tesseract_examples/src/online_planning_example.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3434
#include <Eigen/Geometry>
3535
#include <console_bridge/console.h>
36+
#include <boost/uuid/random_generator.hpp>
3637

3738
#include <trajopt_common/collision_types.h>
3839

@@ -88,6 +89,7 @@ OnlinePlanningExample::OnlinePlanningExample(std::shared_ptr<tesseract_environme
8889
, box_size_(box_size)
8990
, update_start_state_(update_start_state)
9091
, use_continuous_(use_continuous)
92+
, current_trajectory_uuid_(boost::uuids::random_generator()())
9193
{
9294
// Extract necessary kinematic information
9395
manip_ = env_->getKinematicGroup("manipulator");
@@ -266,10 +268,12 @@ bool OnlinePlanningExample::setupProblem(const std::vector<Eigen::VectorXd>& ini
266268
}
267269

268270
// Convert to joint trajectory
269-
tesseract_common::JointTrajectory getJointTrajectory(const std::vector<std::string>& joint_names,
271+
tesseract_common::JointTrajectory getJointTrajectory(boost::uuids::uuid uuid,
272+
const std::vector<std::string>& joint_names,
270273
const tesseract_common::TrajArray& current_trajectory)
271274
{
272275
tesseract_common::JointTrajectory joint_traj;
276+
joint_traj.uuid = uuid;
273277
joint_traj.reserve(static_cast<std::size_t>(current_trajectory.rows()));
274278
double total_time = 0;
275279
for (long i = 0; i < current_trajectory.rows(); ++i)
@@ -289,7 +293,8 @@ void OnlinePlanningExample::updateAndPlotTrajectory(const Eigen::VectorXd& osqp_
289293
current_trajectory_.block(0, 0, steps_, 8) = trajectory;
290294

291295
// Convert to joint trajectory
292-
tesseract_common::JointTrajectory joint_traj = getJointTrajectory(joint_names_, current_trajectory_);
296+
tesseract_common::JointTrajectory joint_traj =
297+
getJointTrajectory(current_trajectory_uuid_, joint_names_, current_trajectory_);
293298
player_.setTrajectory(joint_traj);
294299

295300
// Display Results

0 commit comments

Comments
 (0)