MeshGoalTool.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Robot Operating System code by the University of Osnabrück
5  * Copyright (c) 2015, University of Osnabrück
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  *
21  * 3. Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
30  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  *
39  *
40  * MeshGoalTool.cpp
41  *
42  * author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
43  */
44 
45 
46 #include "MeshGoalTool.hpp"
47 
50 
51 namespace rviz_map_plugin{
53 {
54  shortcut_key_ = 'm';
55  topic_property_ = new rviz::StringProperty( "Topic", "goal",
56  "The topic on which to publish the mesh navigation goals.",
57  getPropertyContainer(), SLOT(updateTopic()), this);
58 
59  switch_bottom_top_ = new rviz::BoolProperty("Switch Bottom/Top",
60  false, "Enable to stwich the bottom and top.",
62 
63 }
64 
66  {
68  setName( "Mesh Goal" );
69  updateTopic();
70  }
71 
73  {
74  pose_pub_ = nh_.advertise<geometry_msgs::PoseStamped>( topic_property_->getStdString(), 1 );
75  }
76 
77  void MeshGoalTool::onPoseSet( const Ogre::Vector3& position, const Ogre::Quaternion& orientation ){
78  geometry_msgs::PoseStamped msg;
79  msg.pose.position.x = position.x;
80  msg.pose.position.y = position.y;
81  msg.pose.position.z = position.z;
82 
83  // ogreToRos(x,y,z) = (-z,-x,y)
84 
85  Ogre::Quaternion ros_orientation;
86 
88  {
89  ros_orientation.FromAxes(
90  -orientation.zAxis(),
91  orientation.xAxis(),
92  -orientation.yAxis()
93  );
94  }
95  else
96  {
97  ros_orientation.FromAxes(
98  -orientation.zAxis(),
99  -orientation.xAxis(),
100  orientation.yAxis()
101  );
102  }
103 
104  msg.pose.orientation.x = ros_orientation.x;
105  msg.pose.orientation.y = ros_orientation.y;
106  msg.pose.orientation.z = ros_orientation.z;
107  msg.pose.orientation.w = ros_orientation.w;
108 
109  msg.header.stamp = ros::Time::now();
110  msg.header.frame_id = context_->getFixedFrame().toStdString();
111  pose_pub_.publish(msg);
112  }
113 
114 }
rviz::BoolProperty::getBool
virtual bool getBool() const
rviz_map_plugin::MeshGoalTool::pose_pub_
ros::Publisher pose_pub_
Publisher.
Definition: MeshGoalTool.hpp:98
rviz::Tool
rviz_map_plugin::MeshGoalTool::topic_property_
rviz::StringProperty * topic_property_
Property for the topic.
Definition: MeshGoalTool.hpp:94
rviz::BoolProperty
rviz::Tool::context_
DisplayContext * context_
rviz_map_plugin::MeshGoalTool
Tool for publishing a goal within a mesh.
Definition: MeshGoalTool.hpp:64
rviz_map_plugin::MeshGoalTool::onInitialize
virtual void onInitialize()
Callback that is executed when tool is initialized.
Definition: MeshGoalTool.cpp:65
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
class_list_macros.h
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
rviz::Tool::shortcut_key_
char shortcut_key_
rviz::StringProperty
rviz::StringProperty::getStdString
std::string getStdString()
MeshGoalTool.hpp
rviz::DisplayContext::getFixedFrame
virtual QString getFixedFrame() const=0
rviz::Tool::getPropertyContainer
virtual Property * getPropertyContainer() const
rviz_map_plugin::MeshGoalTool::MeshGoalTool
MeshGoalTool()
Constructor.
Definition: MeshGoalTool.cpp:52
rviz_map_plugin::MeshGoalTool::onPoseSet
virtual void onPoseSet(const Ogre::Vector3 &position, const Ogre::Quaternion &orientation)
When goal is set, publish result.
Definition: MeshGoalTool.cpp:77
rviz::Tool::setName
void setName(const QString &name)
rviz_map_plugin::MeshGoalTool::updateTopic
void updateTopic()
Updates the topic on which the goal will be published.
Definition: MeshGoalTool.cpp:72
rviz_map_plugin::MeshPoseTool::onInitialize
virtual void onInitialize()
Definition: MeshPoseTool.cpp:71
rviz_map_plugin
Definition: ClusterLabelDisplay.hpp:120
rviz_map_plugin::MeshGoalTool::nh_
ros::NodeHandle nh_
Node handle.
Definition: MeshGoalTool.hpp:100
rviz_map_plugin::MeshGoalTool::switch_bottom_top_
rviz::BoolProperty * switch_bottom_top_
Switch bottom / top for selection.
Definition: MeshGoalTool.hpp:96
ros::Time::now
static Time now()


rviz_map_plugin
Author(s): Sebastian Pütz , Kristin Schmidt , Jan Philipp Vogtherr , Malte kleine Piening
autogenerated on Sun Jan 21 2024 04:06:25