30 : mapper_(mapper), scan_holder_(scan_holder),
31 interactive_mode_(false), nh_(node), state_(state),
32 processor_type_(processor_type)
35 node.
setParam(
"paused_processing",
false);
36 tfB_ = std::make_unique<tf2_ros::TransformBroadcaster>();
42 "karto_scan_visualization",10);
45 std::make_unique<interactive_markers::InteractiveMarkerServer>(
46 "slam_toolbox",
"",
true);
51 "karto_graph_visualization",1);
65 visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback)
71 "Interactive mode is invalid outside processing mode.");
75 const int id = std::stoi(feedback->marker_name,
nullptr, 10) - 1;
78 if (feedback->event_type ==
79 visualization_msgs::InteractiveMarkerFeedback::MOUSE_UP &&
80 feedback->mouse_point_valid)
83 feedback->mouse_point.y,
tf2::getYaw(feedback->pose.orientation)));
87 if (feedback->event_type ==
88 visualization_msgs::InteractiveMarkerFeedback::POSE_UPDATE)
95 double node_yaw, first_node_yaw;
99 q1.
setEuler(0., 0., node_yaw - 3.14159);
112 transform.
setOrigin(tf2::Vector3(feedback->pose.position.x,
113 feedback->pose.position.y, 0.));
117 geometry_msgs::TransformStamped msg;
119 msg.child_frame_id =
"karto_scan_visualization";
120 msg.header.frame_id = feedback->header.frame_id;
122 tfB_->sendTransform(msg);
124 scan.header.frame_id =
"karto_scan_visualization";
142 using ConstVertexMapIterator =
143 karto::MapperGraph::VertexMap::const_iterator;
147 for (ConstVertexMapIterator it = vertices.begin(); it != vertices.end(); ++it)
149 graph_size += it->second.size();
153 bool interactive_mode =
false;
159 const size_t current_marker_count =
marker_array_.markers.size();
162 visualization_msgs::Marker vertex_marker =
165 for (ConstVertexMapIterator outer_it = vertices.begin();
166 outer_it != vertices.end(); ++outer_it)
168 using ConstVertexMapValueIterator =
169 karto::MapperGraph::VertexMap::mapped_type::const_iterator;
170 for (ConstVertexMapValueIterator inner_it = outer_it->second.begin();
171 inner_it != outer_it->second.end(); ++inner_it)
183 visualization_msgs::InteractiveMarker int_marker =
200 if (!interactive_mode)
202 using EdgeList = std::vector<karto::Edge<karto::LocalizedRangeScan>*>;
203 using ConstEdgeListIterator = EdgeList::const_iterator;
205 visualization_msgs::Marker edge_marker =
208 const EdgeList& edges = graph->
GetEdges();
209 for (ConstEdgeListIterator it = edges.begin(); it != edges.end(); ++it)
218 edge_marker.points[0].x = source_pose.
GetX();
219 edge_marker.points[0].y = source_pose.
GetY();
220 edge_marker.points[1].x = target_pose.
GetX();
221 edge_marker.points[1].y = target_pose.
GetY();
226 const size_t next_marker_count =
marker_array_.markers.size();
231 visualization_msgs::Marker deleted_marker;
233 deleted_marker.action = visualization_msgs::Marker::DELETE;
248 slam_toolbox_msgs::LoopClosure::Request& req,
249 slam_toolbox_msgs::LoopClosure::Response& resp)
254 ROS_WARN(
"Called manual loop closure"
255 " with interactive mode disabled. Ignoring.");
264 ROS_WARN(
"No moved nodes to attempt manual loop closure.");
268 ROS_INFO(
"LoopClosureAssistant: Attempting to manual "
269 "loop close with %i moved nodes.", (
int)
moved_nodes_.size());
271 std::map<int, Eigen::Vector3d>::const_iterator it =
moved_nodes_.begin();
275 Eigen::Vector3d(it->second(0),it->second(1), it->second(2)));
290 slam_toolbox_msgs::ToggleInteractive::Request &req,
291 slam_toolbox_msgs::ToggleInteractive::Response &resp)
296 ROS_WARN(
"Called toggle interactive mode with "
297 "interactive mode disabled. Ignoring.");
301 bool interactive_mode;
309 ROS_INFO(
"SlamToolbox: Toggling %s interactive mode.",
310 interactive_mode ?
"on" :
"off");
317 nh_.
setParam(
"paused_processing", interactive_mode);
323 const int&
id,
const Eigen::Vector3d& pose)
331 slam_toolbox_msgs::Clear::Request& req,
332 slam_toolbox_msgs::Clear::Response& resp)
337 ROS_WARN(
"Called Clear changes with interactive mode disabled. Ignoring.");
341 ROS_INFO(
"LoopClosureAssistant: Clearing manual loop closure nodes.");
359 ROS_INFO(
"LoopClosureAssistant: Node %i new manual loop closure "
360 "pose has been recorded.",
id);