-
Notifications
You must be signed in to change notification settings - Fork 709
/
Copy pathdebug.cpp
102 lines (88 loc) · 3.55 KB
/
debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2020 Tier IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "scene_walkway.hpp"
#include <behavior_velocity_planner_common/utilization/util.hpp>
#include <motion_utils/marker/marker_helper.hpp>
#include <motion_utils/trajectory/trajectory.hpp>
#include <tier4_autoware_utils/geometry/geometry.hpp>
#include <tier4_autoware_utils/ros/marker_helper.hpp>
#include <vector>
namespace autoware::behavior_velocity_planner
{
using motion_utils::createSlowDownVirtualWallMarker;
using motion_utils::createStopVirtualWallMarker;
using tier4_autoware_utils::appendMarkerArray;
using tier4_autoware_utils::calcOffsetPose;
using tier4_autoware_utils::createDefaultMarker;
using tier4_autoware_utils::createMarkerColor;
using tier4_autoware_utils::createMarkerScale;
using tier4_autoware_utils::createPoint;
using visualization_msgs::msg::Marker;
namespace planning_utils = ::behavior_velocity_planner::planning_utils;
namespace
{
visualization_msgs::msg::MarkerArray createWalkwayMarkers(
const DebugData & debug_data, const rclcpp::Time & now, const int64_t module_id)
{
int32_t uid = planning_utils::bitShift(module_id);
visualization_msgs::msg::MarkerArray msg;
// Stop point
if (!debug_data.stop_poses.empty()) {
auto marker = createDefaultMarker(
"map", now, "stop point", uid, Marker::POINTS, createMarkerScale(0.25, 0.25, 0.0),
createMarkerColor(1.0, 0.0, 0.0, 0.999));
for (const auto & p : debug_data.stop_poses) {
marker.points.push_back(createPoint(p.position.x, p.position.y, p.position.z));
}
msg.markers.push_back(marker);
}
{
size_t i = 0;
for (const auto & p : debug_data.stop_poses) {
auto marker = createDefaultMarker(
"map", now, "walkway stop judge range", uid + i++, Marker::LINE_STRIP,
createMarkerScale(0.1, 0.1, 0.0), createMarkerColor(1.0, 0.0, 0.0, 0.5));
for (size_t j = 0; j < 50; ++j) {
const auto x = p.position.x + debug_data.stop_judge_range * std::cos(M_PI * 2 / 50 * j);
const auto y = p.position.y + debug_data.stop_judge_range * std::sin(M_PI * 2 / 50 * j);
marker.points.push_back(createPoint(x, y, p.position.z));
}
marker.points.push_back(marker.points.front());
msg.markers.push_back(marker);
}
}
return msg;
}
} // namespace
motion_utils::VirtualWalls WalkwayModule::createVirtualWalls()
{
motion_utils::VirtualWalls virtual_walls;
motion_utils::VirtualWall wall;
wall.text = "walkway";
wall.ns = std::to_string(module_id_) + "_";
wall.style = motion_utils::VirtualWallType::stop;
for (const auto & p : debug_data_.stop_poses) {
wall.pose = calcOffsetPose(p, debug_data_.base_link2front, 0.0, 0.0);
virtual_walls.push_back(wall);
}
return virtual_walls;
}
visualization_msgs::msg::MarkerArray WalkwayModule::createDebugMarkerArray()
{
visualization_msgs::msg::MarkerArray debug_marker_array;
appendMarkerArray(
createWalkwayMarkers(debug_data_, this->clock_->now(), module_id_), &debug_marker_array);
return debug_marker_array;
}
} // namespace autoware::behavior_velocity_planner