Main Page
Namespaces
Classes
Files
File List
src
RobotGoalsArrayDisplay.cpp
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
#include <OGRE/OgreSceneNode.h>
31
#include <OGRE/OgreSceneManager.h>
32
33
#include <
tf/transform_listener.h
>
34
35
#include <
rviz/visualization_manager.h
>
36
#include <
rviz/properties/color_property.h
>
37
#include <
rviz/properties/float_property.h
>
38
#include <
rviz/frame_manager.h
>
39
40
#include "
tuw_multi_robot_rviz/RobotGoalsArrayDisplay.h
"
41
#include "
tuw_multi_robot_rviz/RobotGoalsArrayVisual.h
"
42
43
namespace
tuw_multi_robot_rviz
{
44
45
// The constructor must have no arguments, so we can't give the
46
// constructor the parameters it needs to fully initialize.
47
RobotGoalsArrayDisplay::RobotGoalsArrayDisplay
() {
48
property_scale_pose_
=
new
rviz::FloatProperty
(
"Scale Pose"
, 0.4,
49
"Scale of the pose's pose."
,
50
this
, SLOT (
updateScalePose
() ) );
51
property_scale_pose_
->
setMin
( 0 );
52
property_scale_pose_
->
setMax
( 1 );
53
54
property_color_pose_
=
new
rviz::ColorProperty
(
"Color Pose"
, QColor ( 204, 51, 0 ),
55
"Color to draw the pose's pose."
,
56
this
, SLOT (
updateColorPose
() ) );
57
}
58
59
// After the top-level rviz::Display::initialize() does its own setup,
60
// it calls the subclass's onInitialize() function. This is where we
61
// instantiate all the workings of the class. We make sure to also
62
// call our immediate super-class's onInitialize() function, since it
63
// does important stuff setting up the message filter.
64
//
65
// Note that "MFDClass" is a typedef of
66
// ``MessageFilterDisplay<message type>``, to save typing that long
67
// templated class name every time you need to refer to the
68
// superclass.
69
void
RobotGoalsArrayDisplay::onInitialize
() {
70
MFDClass::onInitialize
();
71
visual_
.reset (
new
RobotGoalsArrayVisual
(
context_
->
getSceneManager
(),
scene_node_
) );
72
}
73
74
RobotGoalsArrayDisplay::~RobotGoalsArrayDisplay
() {
75
}
76
77
// Clear the visual by deleting its object.
78
void
RobotGoalsArrayDisplay::reset
() {
79
MFDClass::reset
();
80
}
81
82
// Set the current scale for the visual's pose.
83
void
RobotGoalsArrayDisplay::updateScalePose
() {
84
float
scale =
property_scale_pose_
->
getFloat
();
85
visual_
->setScalePose ( scale );
86
}
87
88
// Set the current color for the visual's pose.
89
void
RobotGoalsArrayDisplay::updateColorPose
() {
90
Ogre::ColourValue color =
property_color_pose_
->
getOgreColor
();
91
visual_
->setColorPose ( color );
92
}
93
94
// This is our callback to handle an incoming message.
95
void
RobotGoalsArrayDisplay::processMessage
(
const
tuw_multi_robot_msgs::RobotGoalsArray::ConstPtr& msg ) {
96
// Here we call the rviz::FrameManager to get the transform from the
97
// fixed frame to the frame in the header of this Imu message. If
98
// it fails, we can't do anything else so we return.
99
Ogre::Quaternion orientation;
100
Ogre::Vector3 position;
101
102
if
( !
context_
->
getFrameManager
()->
getTransform
( msg->header.frame_id, msg->header.stamp, position, orientation ) ) {
103
ROS_DEBUG
(
"Error transforming from frame '%s' to frame '%s'"
,
104
msg->header.frame_id.c_str(), qPrintable (
fixed_frame_
) );
105
return
;
106
}
107
108
// Now set or update the contents of the visual.
109
visual_
->setMessage ( msg );
110
visual_
->setFramePosition ( position );
111
visual_
->setFrameOrientation ( orientation );
112
visual_
->setScalePose (
property_scale_pose_
->
getFloat
() );
113
visual_
->setColorPose (
property_color_pose_
->
getOgreColor
() );
114
}
115
116
}
// end namespace tuw_geometry_rviz
117
118
// Tell pluginlib about this class. It is important to do this in
119
// global scope, outside our package's namespace.
120
#include <
pluginlib/class_list_macros.h
>
121
PLUGINLIB_EXPORT_CLASS
(
tuw_multi_robot_rviz::RobotGoalsArrayDisplay
,
rviz::Display
)
122
rviz::FloatProperty::setMin
void setMin(float min)
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::property_scale_pose_
rviz::FloatProperty * property_scale_pose_
Definition:
RobotGoalsArrayDisplay.h:92
transform_listener.h
rviz::FloatProperty::setMax
void setMax(float max)
rviz::ColorProperty::getOgreColor
Ogre::ColourValue getOgreColor() const
rviz::MessageFilterDisplay< tuw_multi_robot_msgs::RobotGoalsArray >::onInitialize
virtual void onInitialize()
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::RobotGoalsArrayDisplay
RobotGoalsArrayDisplay()
Definition:
RobotGoalsArrayDisplay.cpp:47
tuw_multi_robot_rviz
Definition:
MultiRobotGoalSelector.h:61
rviz::Display::context_
DisplayContext * context_
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::visual_
boost::shared_ptr< RobotGoalsArrayVisual > visual_
Definition:
RobotGoalsArrayDisplay.h:89
tuw_multi_robot_rviz::RobotGoalsArrayDisplay
Definition:
RobotGoalsArrayDisplay.h:59
rviz::FloatProperty::getFloat
virtual float getFloat() const
rviz::MessageFilterDisplay< tuw_multi_robot_msgs::RobotGoalsArray >::reset
virtual void reset()
rviz::FloatProperty
rviz::Display::scene_node_
Ogre::SceneNode * scene_node_
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::property_color_pose_
rviz::ColorProperty * property_color_pose_
Definition:
RobotGoalsArrayDisplay.h:93
rviz::ColorProperty
rviz::Display::fixed_frame_
QString fixed_frame_
rviz::Display
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::updateColorPose
void updateColorPose()
Definition:
RobotGoalsArrayDisplay.cpp:89
class_list_macros.h
rviz::DisplayContext::getFrameManager
virtual FrameManager * getFrameManager() const =0
RobotGoalsArrayVisual.h
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::reset
virtual void reset()
Definition:
RobotGoalsArrayDisplay.cpp:78
float_property.h
visualization_manager.h
color_property.h
rviz::DisplayContext::getSceneManager
virtual Ogre::SceneManager * getSceneManager() const =0
tuw_multi_robot_rviz::RobotGoalsArrayVisual
Definition:
RobotGoalsArrayVisual.h:53
rviz::FrameManager::getTransform
bool getTransform(const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
RobotGoalsArrayDisplay.h
frame_manager.h
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::~RobotGoalsArrayDisplay
virtual ~RobotGoalsArrayDisplay()
Definition:
RobotGoalsArrayDisplay.cpp:74
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::updateScalePose
void updateScalePose()
Definition:
RobotGoalsArrayDisplay.cpp:83
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::onInitialize
virtual void onInitialize()
Definition:
RobotGoalsArrayDisplay.cpp:69
tuw_multi_robot_rviz::RobotGoalsArrayDisplay::processMessage
void processMessage(const tuw_multi_robot_msgs::RobotGoalsArray::ConstPtr &msg)
Definition:
RobotGoalsArrayDisplay.cpp:95
ROS_DEBUG
#define ROS_DEBUG(...)
tuw_multi_robot_rviz
Author(s): Benjamin Binder
autogenerated on Mon Jun 10 2019 15:42:40