NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
trajectory_display.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef MOBILITY_PLANNER_QP_TRAJ_OPT_ROS_SRC_TRAJECTORY_DISPLAY_H_
20 #define MOBILITY_PLANNER_QP_TRAJ_OPT_ROS_SRC_TRAJECTORY_DISPLAY_H_
21 
22 #ifndef Q_MOC_RUN
23 #include <rviz/message_filter_display.h>
24 #include <traj_opt_msgs/Trajectory.h>
25 #include <boost/circular_buffer.hpp>
26 #endif
27 
28 namespace Ogre {
29 class SceneNode;
30 }
31 
32 namespace rviz {
33 class ColorProperty;
34 class FloatProperty;
35 class IntProperty;
36 class EnumProperty;
37 class BoolProperty;
38 }
39 
40 // All the source in this plugin is in its own namespace. This is not
41 // required but is good practice.
42 namespace traj_opt {
43 
44 class TrajectoryVisual;
45 
46 // BEGIN_TUTORIAL
47 // Here we declare our new subclass of rviz::Display. Every display
48 // which can be listed in the "Displays" panel is a subclass of
49 // rviz::Display.
50 //
51 // TrajectoryDisplay will show a 3D arrow showing the direction and magnitude
52 // of the TRAJECTORY acceleration vector. The base of the arrow will be at
53 // the frame listed in the header of the Trajectory message, and the
54 // direction of the arrow will be relative to the orientation of that
55 // frame. It will also optionally show a history of recent
56 // acceleration vectors, which will be stored in a circular buffer.
57 //
58 // The TrajectoryDisplay class itself just implements the circular buffer,
59 // editable parameters, and Display subclass machinery. The visuals
60 // themselves are represented by a separate class, TrajectoryVisual. The
61 // idiom for the visuals is that when the objects exist, they appear
62 // in the scene, and when they are deleted, they disappear.
64  : public rviz::MessageFilterDisplay<traj_opt_msgs::Trajectory> {
65  Q_OBJECT // NOLINT
66  public
67  : // NOLINT
68  // Constructor. pluginlib::ClassLoader creates instances by calling
69  // the default constructor, so make sure you have one.
71  virtual ~TrajectoryDisplay();
72 
73  // Overrides of protected virtual functions from Display. As much
74  // as possible, when Displays are not enabled, they should not be
75  // subscribed to incoming data and should not show anything in the
76  // 3D view. These functions are where these connections are made
77  // and broken.
78  protected:
79  virtual void onInitialize();
80 
81  // A helper to clear this display back to the initial state.
82  virtual void reset();
83 
84  // These Qt slots get connected to signals indicating changes in the
85  // user-editable properties.
86  private Q_SLOTS: // NOLINT
87  void updateColorAndAlpha();
88  void randomizeColor();
89  void updateHistoryLength();
90  void updateScale();
91  void updateStyle();
92  void updateSampleLength();
93  // Function to handle an incoming ROS message.
94  private:
95  void processMessage(const traj_opt_msgs::Trajectory::ConstPtr& msg);
96 
97  // Storage for the list of visuals. It is a circular buffer where
98  // data gets popped from the front (oldest) and pushed to the back (newest)
99  boost::circular_buffer<boost::shared_ptr<TrajectoryVisual> > visuals_;
100 
101  // User-editable property variables.
102  rviz::ColorProperty* color_property_;
103  rviz::FloatProperty* alpha_property_;
104  rviz::ColorProperty* color_property_v_;
105  rviz::ColorProperty* color_property_a_;
106 
107  rviz::BoolProperty* use_v_property_;
108  rviz::BoolProperty* use_a_property_;
109 
110  rviz::FloatProperty* thickness_property_;
111  rviz::IntProperty* history_length_property_;
112  rviz::IntProperty* traj_samples_property_;
113  rviz::IntProperty* tangent_samples_property_;
114  rviz::EnumProperty* style_property_;
115 };
116 // END_TUTORIAL
117 
118 } // end namespace traj_opt
119 
120 #endif // MOBILITY_PLANNER_QP_TRAJ_OPT_ROS_SRC_TRAJECTORY_DISPLAY_H_
121 // %EndTag(FULL_SOURCE)%
traj_opt::TrajectoryDisplay::TrajectoryDisplay
TrajectoryDisplay()
Definition: trajectory_display.cpp:40
Ogre
Definition: trajectory_display.h:28
traj_opt::TrajectoryDisplay
Definition: trajectory_display.h:63
traj_opt::TrajectoryDisplay::~TrajectoryDisplay
virtual ~TrajectoryDisplay()
Definition: trajectory_display.cpp:131
rviz
Definition: trajectory_display.h:32
traj_opt
Definition: msg_traj.h:27
traj_opt::TrajectoryDisplay::onInitialize
virtual void onInitialize()
Definition: trajectory_display.cpp:119
traj_opt::TrajectoryDisplay::reset
virtual void reset()
Definition: trajectory_display.cpp:134