trajectory_display.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015, University of Colorado, Boulder
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Univ of CO, Boulder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman
36  Desc: Wraps a trajectory_visualization playback class for Rviz into a stand alone display
37 */
38 
41 
42 namespace moveit_rviz_plugin
43 {
44 TrajectoryDisplay::TrajectoryDisplay() : Display(), load_robot_model_(false)
45 {
46  // The robot description property is only needed when using the trajectory playback standalone (not within motion
47  // planning plugin)
49  "Robot Description", "robot_description", "The name of the ROS parameter where the URDF for the robot is loaded",
50  this, SLOT(changedRobotDescription()), this);
51 
52  trajectory_visual_.reset(new TrajectoryVisualization(this, this));
53 }
54 
56 {
57 }
58 
60 {
61  Display::onInitialize();
62 
64 }
65 
67 {
68  load_robot_model_ = false;
70 
71  if (!rdf_loader_->getURDF())
72  {
73  this->setStatus(rviz::StatusProperty::Error, "Robot Model",
74  "Failed to load from parameter " + robot_description_property_->getString());
75  return;
76  }
77  this->setStatus(rviz::StatusProperty::Ok, "Robot Model", "Successfully loaded");
78 
79  const srdf::ModelSharedPtr& srdf =
80  rdf_loader_->getSRDF() ? rdf_loader_->getSRDF() : srdf::ModelSharedPtr(new srdf::Model());
81  robot_model_.reset(new robot_model::RobotModel(rdf_loader_->getURDF(), srdf));
82 
83  // Send to child class
84  trajectory_visual_->onRobotModelLoaded(robot_model_);
85  trajectory_visual_->onEnable();
86 }
87 
89 {
90  Display::reset();
92  trajectory_visual_->reset();
93 }
94 
96 {
97  Display::onEnable();
98  load_robot_model_ = true; // allow loading of robot model in update()
99 }
100 
102 {
103  Display::onDisable();
104  trajectory_visual_->onDisable();
105 }
106 
107 void TrajectoryDisplay::update(float wall_dt, float ros_dt)
108 {
109  Display::update(wall_dt, ros_dt);
110 
111  if (load_robot_model_)
112  loadRobotModel();
113 
114  trajectory_visual_->update(wall_dt, ros_dt);
115 }
116 
117 void TrajectoryDisplay::setName(const QString& name)
118 {
119  BoolProperty::setName(name);
120  trajectory_visual_->setName(name);
121 }
122 
124 {
125  if (isEnabled())
126  reset();
127  else
128  loadRobotModel();
129 }
130 
131 } // namespace moveit_rviz_plugin
DisplayContext * context_
ros::NodeHandle update_nh_
Ogre::SceneNode * scene_node_
std::string getStdString()
bool isEnabled() const
rviz::StringProperty * robot_description_property_
boost::shared_ptr< Model > ModelSharedPtr
void changedRobotDescription()
Slot Event Functions.
robot_model::RobotModelConstPtr robot_model_
virtual void update(float wall_dt, float ros_dt)
TrajectoryVisualizationPtr trajectory_visual_
virtual void setStatus(StatusProperty::Level level, const QString &name, const QString &text)


visualization
Author(s): Ioan Sucan , Dave Coleman , Sachin Chitta
autogenerated on Sun Oct 18 2020 13:19:09