Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
utils.cpp
1 // Copyright (c) 2023 Alberto J. Tudela Roldán
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "nav2_graceful_controller/utils.hpp"
16 
17 namespace nav2_graceful_controller
18 {
19 
20 geometry_msgs::msg::PointStamped createMotionTargetMsg(
21  const geometry_msgs::msg::PoseStamped & motion_target)
22 {
23  geometry_msgs::msg::PointStamped motion_target_point;
24  motion_target_point.header = motion_target.header;
25  motion_target_point.point = motion_target.pose.position;
26  motion_target_point.point.z = 0.01;
27  return motion_target_point;
28 }
29 
30 visualization_msgs::msg::Marker createSlowdownMarker(
31  const geometry_msgs::msg::PoseStamped & motion_target, const double & slowdown_radius)
32 {
33  visualization_msgs::msg::Marker slowdown_marker;
34  slowdown_marker.header = motion_target.header;
35  slowdown_marker.ns = "slowdown";
36  slowdown_marker.id = 0;
37  slowdown_marker.type = visualization_msgs::msg::Marker::SPHERE;
38  slowdown_marker.action = visualization_msgs::msg::Marker::ADD;
39  slowdown_marker.pose = motion_target.pose;
40  slowdown_marker.pose.position.z = 0.01;
41  slowdown_marker.scale.x = slowdown_radius * 2.0;
42  slowdown_marker.scale.y = slowdown_radius * 2.0;
43  slowdown_marker.scale.z = 0.02;
44  slowdown_marker.color.a = 0.2;
45  slowdown_marker.color.r = 0.0;
46  slowdown_marker.color.g = 1.0;
47  slowdown_marker.color.b = 0.0;
48  return slowdown_marker;
49 }
50 
51 } // namespace nav2_graceful_controller