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

How to get the trajectory from the warehouse_viewer?

asked 2013-03-24 23:54:23 -0500

RosRos gravatar image

Hello,

I use the warehouse_viewer to plan the trajectories for my robot. Now I just want to write a node which requests for the current trajectory, but I have no idea how to do that without changing the sourcecode.

Any ideas? Thanks a lot

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-03-26 05:21:11 -0500

GuiHome gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-03-24 23:54:23 -0500

Seen: 113 times

Last updated: Mar 26 '13