|
1 | 1 | #include <geometry_msgs/PoseStamped.h> |
| 2 | +#include <geometry_msgs/PointStamped.h> |
2 | 3 |
|
3 | 4 | #include <OgreMovableObject.h> |
4 | 5 | #include <OgreSceneManager.h> |
@@ -102,8 +103,12 @@ ToolCursor::ToolCursor() |
102 | 103 | shortcut_key_ = 'c'; |
103 | 104 |
|
104 | 105 |
|
105 | | - topic_property_ = new rviz::StringProperty("Topic", "/selection_point", |
106 | | - "The topic on which to publish points", |
| 106 | + pose_topic_property_ = new rviz::StringProperty("Pose Topic", "/selection_point", |
| 107 | + "The topic on which to publish pose messages", |
| 108 | + getPropertyContainer(), SLOT(updateTopic()), this); |
| 109 | + |
| 110 | + point_topic_property_ = new rviz::StringProperty("Point Topic", "/clicked_point", |
| 111 | + "The topic on which to publish point messages", |
107 | 112 | getPropertyContainer(), SLOT(updateTopic()), this); |
108 | 113 |
|
109 | 114 | patch_size_property_ = new rviz::IntProperty("Patch Size", 10, |
@@ -151,7 +156,8 @@ void ToolCursor::deactivate() |
151 | 156 |
|
152 | 157 | void ToolCursor::updateTopic() |
153 | 158 | { |
154 | | - pub_ = nh_.advertise<geometry_msgs::PoseStamped>(topic_property_->getStdString(), 1, true); |
| 159 | + pose_pub_ = nh_.advertise<geometry_msgs::PoseStamped>(pose_topic_property_->getStdString(), 1, true); |
| 160 | + point_pub_ = nh_.advertise<geometry_msgs::PointStamped>(point_topic_property_->getStdString(), 1, true); |
155 | 161 | } |
156 | 162 |
|
157 | 163 | int ToolCursor::processMouseEvent(rviz::ViewportMouseEvent& event) |
@@ -185,20 +191,30 @@ int ToolCursor::processMouseEvent(rviz::ViewportMouseEvent& event) |
185 | 191 | if(event.leftUp()) |
186 | 192 | { |
187 | 193 | // Publish a point message upon release of the left mouse button |
188 | | - geometry_msgs::PoseStamped msg; |
189 | | - msg.header.frame_id = context_->getFixedFrame().toStdString(); |
190 | | - msg.header.stamp = ros::Time::now(); |
| 194 | + geometry_msgs::PoseStamped pose_msg; |
| 195 | + pose_msg.header.frame_id = context_->getFixedFrame().toStdString(); |
| 196 | + pose_msg.header.stamp = ros::Time::now(); |
| 197 | + |
| 198 | + pose_msg.pose.position.x = static_cast<double>(position.x); |
| 199 | + pose_msg.pose.position.y = static_cast<double>(position.y); |
| 200 | + pose_msg.pose.position.z = static_cast<double>(position.z); |
| 201 | + |
| 202 | + pose_msg.pose.orientation.w = static_cast<double>(q.w); |
| 203 | + pose_msg.pose.orientation.x = static_cast<double>(q.x); |
| 204 | + pose_msg.pose.orientation.y = static_cast<double>(q.y); |
| 205 | + pose_msg.pose.orientation.z = static_cast<double>(q.z); |
| 206 | + |
| 207 | + pose_pub_.publish(pose_msg); |
191 | 208 |
|
192 | | - msg.pose.position.x = static_cast<double>(position.x); |
193 | | - msg.pose.position.y = static_cast<double>(position.y); |
194 | | - msg.pose.position.z = static_cast<double>(position.z); |
| 209 | + geometry_msgs::PointStamped point_msg; |
| 210 | + point_msg.header.frame_id = context_->getFixedFrame().toStdString(); |
| 211 | + point_msg.header.stamp = ros::Time::now(); |
195 | 212 |
|
196 | | - msg.pose.orientation.w = static_cast<double>(q.w); |
197 | | - msg.pose.orientation.x = static_cast<double>(q.x); |
198 | | - msg.pose.orientation.y = static_cast<double>(q.y); |
199 | | - msg.pose.orientation.z = static_cast<double>(q.z); |
| 213 | + point_msg.point.x = static_cast<double>(position.x); |
| 214 | + point_msg.point.y = static_cast<double>(position.y); |
| 215 | + point_msg.point.z = static_cast<double>(position.z); |
200 | 216 |
|
201 | | - pub_.publish(msg); |
| 217 | + point_pub_.publish(point_msg); |
202 | 218 | } |
203 | 219 | } |
204 | 220 | else |
|
0 commit comments