SMACC
Loading...
Searching...
No Matches
smacc_rviz_display.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Willow Garage, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Willow Garage, Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef IMU_DISPLAY_H
31#define IMU_DISPLAY_H
32
33#ifndef Q_MOC_RUN
34#include <ros/ros.h>
35#include <ros/network.h>
36#endif
37
38#include <boost/circular_buffer.hpp>
39
40#include <smacc_msgs/SmaccStatus.h>
41#include <rviz/message_filter_display.h>
42#include <rviz/ogre_helpers/arrow.h>
43
44
45using namespace Ogre;
46using namespace rviz;
47
48// All the source in this plugin is in its own namespace. This is not
49// required but is good practice.
50namespace smacc_rviz_plugin
51{
52
53class ImuVisual;
54
55// BEGIN_TUTORIAL
56// Here we declare our new subclass of rviz::Display. Every display
57// which can be listed in the "Displays" panel is a subclass of
58// rviz::Display.
59//
60// SmaccRvizDisplay will show a 3D arrow showing the direction and magnitude
61// of the IMU acceleration vector. The base of the arrow will be at
62// the frame listed in the header of the Imu message, and the
63// direction of the arrow will be relative to the orientation of that
64// frame. It will also optionally show a history of recent
65// acceleration vectors, which will be stored in a circular buffer.
66//
67// The SmaccRvizDisplay class itself just implements the circular buffer,
68// editable parameters, and Display subclass machinery. The visuals
69// themselves are represented by a separate class, ImuVisual. The
70// idiom for the visuals is that when the objects exist, they appear
71// in the scene, and when they are deleted, they disappear.
72class SmaccRvizDisplay: public rviz::Display
73{
74Q_OBJECT
75public:
76 // Constructor. pluginlib::ClassLoader creates instances by calling
77 // the default constructor, so make sure you have one.
79 virtual ~SmaccRvizDisplay();
80
81 virtual void subscribe();
82 virtual void unsubscribe();
83
84 // Overrides of protected virtual functions from Display. As much
85 // as possible, when Displays are not enabled, they should not be
86 // subscribed to incoming data and should not show anything in the
87 // 3D view. These functions are where these connections are made
88 // and broken.
89protected:
90 virtual void onInitialize();
91
92 // A helper to clear this display back to the initial state.
93 virtual void reset();
94
95 // These Qt slots get connected to signals indicating changes in the user-editable properties.
96private Q_SLOTS:
97 void updateCurrentState();
98 void updateTopic();
99
100 // Function to handle an incoming ROS message.
101private:
102
103 void processMessage( const smacc_msgs::SmaccStatus::ConstPtr& msg );
104
105 // Storage for the list of visuals. It is a circular buffer where
106 // data gets popped from the front (oldest) and pushed to the back (newest)
107 //boost::circular_buffer<boost::shared_ptr<ImuVisual> > visuals_;
108
109 // User-editable property variables.
110 /*
111 rviz::ColorProperty* color_property_;
112 rviz::FloatProperty* alpha_property_;
113 rviz::IntProperty* history_length_property_;
114 */
115
116 rviz::StringProperty* current_state_;
117 rviz::RosTopicProperty* topic_property_ ;
118 ros::NodeHandle nh_;
119 ros::Subscriber sub_;
120};
121// END_TUTORIAL
122
123} // end namespace rviz_plugin_tutorials
124
125#endif // IMU_DISPLAY_H
126// %EndTag(FULL_SOURCE)%
void processMessage(const smacc_msgs::SmaccStatus::ConstPtr &msg)
rviz::RosTopicProperty * topic_property_