ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi,

We also wanted to access the trajectories but did not find a way to do that without modifying the code or accessing the mongodb that saves the generated trajectories. In case you don't know how to change the source code, here are the 4 modifications we did on the electric version (I cannot give you a patch as our modified version contains other stuff). We modified the planning_scene_warehouse_viewer.h by adding a button in the public slots: section

/// @brief Called when the user publishes a trajectory
  void publishButtonPressed();

then in planning_scene_warehouse_viewer.cpp

      QPushButton* publishTrajectoryButton = new QPushButton(trajectoryBox);
      publishTrajectoryButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
      publishTrajectoryButton->setText("Publish Trajectory");
      publishTrajectoryButton->setToolTip("Publish the currently selected trajectory.");

and

trajectoryBoxLayout->addWidget(publishTrajectoryButton);

and

connect(publishTrajectoryButton, SIGNAL(clicked()), this, SLOT(publishButtonPressed()));

and finally the function

void WarehouseViewer::publishButtonPressed()
{
  if(selected_trajectory_name_ != "")
  {
    TrajectoryData& trajectory = trajectory_map_[selected_motion_plan_name_][selected_trajectory_name_];
    trajectory_msgs::JointTrajectory mytrajectory_msg=trajectory.getTrajectory();
    traj_publisher_.publish(mytrajectory_msg);
  }
  else
  {
    QMessageBox msg(QMessageBox::Warning, "Publish Trajectory", "No Trajectory Selected!");
    msg.addButton("Ok", QMessageBox::AcceptRole);
    msg.exec();
  }
}

and then advertized a publisher in move_arm_utils.cpp in the publisher section

traj_publisher_ = nh_.advertise<trajectory_msgs::JointTrajectory> ("/generated_trajectory", 128);

and declared it in move_arm_utils.cpp near the other publishers of the PlanningSceneEditor class

ros::Publisher traj_publisher_;

the program will output the trajectory on /generated_trajectory topic each time you press the button. Your node can listen to that topic.

Hope this helps.