SMACC
Loading...
Searching...
No Matches
imu_visual.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_VISUAL_H
31#define IMU_VISUAL_H
32
33#include <sensor_msgs/Imu.h>
34#include <rviz/ogre_helpers/arrow.h>
35
36using namespace rviz;
37using namespace Ogre;
38
39namespace smacc_rviz_plugin
40{
41
42// BEGIN_TUTORIAL
43// Declare the visual class for this display.
44//
45// Each instance of ImuVisual represents the visualization of a single
46// sensor_msgs::Imu message. Currently it just shows an arrow with
47// the direction and magnitude of the acceleration vector, but could
48// easily be expanded to include more of the message data.
50{
51public:
52 // Constructor. Creates the visual stuff and puts it into the
53 // scene, but in an unconfigured state.
54 ImuVisual( Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node );
55
56 // Destructor. Removes the visual stuff from the scene.
57 virtual ~ImuVisual();
58
59 // Configure the visual to show the data in the message.
60 void setMessage( const sensor_msgs::Imu::ConstPtr& msg );
61
62 // Set the pose of the coordinate frame the message refers to.
63 // These could be done inside setMessage(), but that would require
64 // calls to FrameManager and error handling inside setMessage(),
65 // which doesn't seem as clean. This way ImuVisual is only
66 // responsible for visualization.
67 void setFramePosition( const Ogre::Vector3& position );
68 void setFrameOrientation( const Ogre::Quaternion& orientation );
69
70 // Set the color and alpha of the visual, which are user-editable
71 // parameters and therefore don't come from the Imu message.
72 void setColor( float r, float g, float b, float a );
73
74private:
75 // The object implementing the actual arrow shape
76 boost::shared_ptr<rviz::Arrow> acceleration_arrow_;
77
78 // A SceneNode whose pose is set to match the coordinate frame of
79 // the Imu message header.
80 Ogre::SceneNode* frame_node_;
81
82 // The SceneManager, kept here only so the destructor can ask it to
83 // destroy the ``frame_node_``.
84 Ogre::SceneManager* scene_manager_;
85};
86// END_TUTORIAL
87
88} // end namespace rviz_plugin_tutorials
89
90#endif // IMU_VISUAL_H
void setFramePosition(const Ogre::Vector3 &position)
Definition: imu_visual.cpp:86
void setMessage(const sensor_msgs::Imu::ConstPtr &msg)
Definition: imu_visual.cpp:66
void setColor(float r, float g, float b, float a)
Definition: imu_visual.cpp:97
boost::shared_ptr< rviz::Arrow > acceleration_arrow_
Definition: imu_visual.h:76
void setFrameOrientation(const Ogre::Quaternion &orientation)
Definition: imu_visual.cpp:91
Ogre::SceneManager * scene_manager_
Definition: imu_visual.h:84
Ogre::SceneNode * frame_node_
Definition: imu_visual.h:80