Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RJD-1457/traffic_sink_refactor #1464

Merged
merged 46 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
09de4c5
rename argument and member variables
hakuturu583 Nov 8, 2024
fddf3db
rename variable in TrafficController class
hakuturu583 Nov 8, 2024
1d62279
add get_entity_type function
hakuturu583 Nov 8, 2024
4824083
add sinkable_entity_type variable
hakuturu583 Nov 8, 2024
61577fc
add sinkable_entity_type to the configuration class
hakuturu583 Nov 8, 2024
25b59a5
add doxygen comment
hakuturu583 Nov 8, 2024
f7a2b92
enable compare entity type
hakuturu583 Nov 8, 2024
243a1d1
enable set traffic sink in cpp scenario
hakuturu583 Nov 8, 2024
22c4470
enable sink vehicle
hakuturu583 Nov 8, 2024
ff27398
add testcase for autosink
hakuturu583 Nov 8, 2024
c15b04e
fix typo
hakuturu583 Nov 8, 2024
9d3a626
fix typo
hakuturu583 Nov 8, 2024
8dc26c4
fix typo
hakuturu583 Nov 8, 2024
db65427
modify launch file
hakuturu583 Nov 11, 2024
91b19d3
remap debug marker
hakuturu583 Nov 11, 2024
ba75cc2
use uint8_t instead of traffic_simulator_msgs::msg::EntityType
hakuturu583 Nov 12, 2024
8340952
apply reformat
hakuturu583 Nov 12, 2024
6d3b4bf
remove sonarcloud warning
hakuturu583 Nov 13, 2024
56f31cc
remove warning
hakuturu583 Nov 13, 2024
51dfd98
Merge branch 'master' into feature/enable_specify_entity_type_in_auto…
hakuturu583 Nov 13, 2024
66ea125
fix check condition
hakuturu583 Nov 14, 2024
060bc56
Merge branch 'master' of https://github.com/tier4/scenario_simulator_…
hakuturu583 Nov 14, 2024
2e6d5d3
Merge remote-tracking branch 'origin/feature/enable_specify_entity_ty…
hakuturu583 Nov 14, 2024
a18cd1b
Merge tag '6.0.1' into RJD-1457/traffic_sink_refactor
robomic Nov 28, 2024
2095cba
TrafficSink refactor with despawn functionality
robomic Nov 28, 2024
ebec879
spell-check happy
robomic Nov 28, 2024
6898d27
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 3, 2024
2f1da24
reorder fix
robomic Dec 3, 2024
162d11d
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 4, 2024
9a30039
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 9, 2024
8a5d557
remove lanelet_id from the constructor
robomic Dec 9, 2024
4aefb2a
review suggestions
robomic Dec 9, 2024
7be6fce
AutoSinkConfig
robomic Dec 9, 2024
69918d7
TrafficSinkConfig
robomic Dec 9, 2024
2d56a8b
simplify auto_sink logic
robomic Dec 9, 2024
c2d4f1e
sink pedestrian test fix
robomic Dec 9, 2024
41866ce
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 10, 2024
ce85613
code style
robomic Dec 10, 2024
562b1ad
code style
robomic Dec 10, 2024
0cca110
remove unnecessary funcs
robomic Dec 10, 2024
d0403a4
remove unnecessary include directives
robomic Dec 10, 2024
4925bc7
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 10, 2024
bc86417
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 11, 2024
43f7e10
Merge branch 'master' into RJD-1457/traffic_sink_refactor
robomic Dec 18, 2024
539580d
style fix
robomic Dec 18, 2024
25aac0e
Merge branch 'master' into RJD-1457/traffic_sink_refactor
hakuturu583 Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
code style
  • Loading branch information
robomic committed Dec 10, 2024
commit ce85613d3f17af93294158fc9de3e93449235bcd
12 changes: 4 additions & 8 deletions mock/cpp_mock_scenarios/src/traffic_sink/auto_sink_vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ class AutoSinkVehicleScenario : public cpp_mock_scenarios::CppScenarioNode

void onInitialize() override
{
const auto canonicalized_lanelet_pose =
const auto map_pose = traffic_simulator::pose::toMapPose(
traffic_simulator::helper::constructCanonicalizedLaneletPose(
34774, 11.0, 0.0, api_.getHdmapUtils());
api_.spawn(
"car", traffic_simulator::pose::toMapPose(canonicalized_lanelet_pose),
getVehicleParameters());
api_.spawn(
"bob", traffic_simulator::pose::toMapPose(canonicalized_lanelet_pose),
getPedestrianParameters());
34774, 11.0, 0.0, api_.getHdmapUtils()));
api_.spawn("car", map_pose, getVehicleParameters());
api_.spawn("bob", map_pose, getPedestrianParameters());
}
};
} // namespace cpp_mock_scenarios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class TrafficController
auto module_ptr = std::make_shared<T>(std::forward<Ts>(xs)...);
modules_.emplace_back(module_ptr);
}
void execute(const double current_time, const double step_time);
auto makeDebugMarker() const -> const visualization_msgs::msg::MarkerArray;
auto execute(const double current_time, const double step_time) -> void;
auto makeDebugMarker() const -> visualization_msgs::msg::MarkerArray;

private:
void generateAutoSinks(const std::set<std::uint8_t> & auto_sink_entity_types);
const std::shared_ptr<entity::EntityManager> entity_manager_ptr;
auto appendAutoSinks(const std::set<std::uint8_t> & auto_sink_entity_types) -> void;
const std::shared_ptr<entity::EntityManager> entity_manager_ptr_;
std::vector<std::shared_ptr<TrafficModuleBase>> modules_;
};
} // namespace traffic
Expand Down
21 changes: 11 additions & 10 deletions simulation/traffic_simulator/src/traffic/traffic_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,43 @@ namespace traffic
TrafficController::TrafficController(
const std::shared_ptr<entity::EntityManager> entity_manager_ptr,
const std::set<std::uint8_t> auto_sink_entity_types)
: entity_manager_ptr(entity_manager_ptr), modules_()
: entity_manager_ptr_(entity_manager_ptr), modules_()
{
if (not auto_sink_entity_types.empty()) {
generateAutoSinks(auto_sink_entity_types);
appendAutoSinks(auto_sink_entity_types);
}
}

void TrafficController::generateAutoSinks(const std::set<std::uint8_t> & auto_sink_entity_types)
auto TrafficController::appendAutoSinks(const std::set<std::uint8_t> & auto_sink_entity_types)
-> void
{
const auto hdmap_utils_ptr = entity_manager_ptr->getHdmapUtils();
static constexpr double sink_radius = 1.0;
const auto hdmap_utils_ptr = entity_manager_ptr_->getHdmapUtils();
for (const auto & lanelet_id : hdmap_utils_ptr->getLaneletIds()) {
if (hdmap_utils_ptr->getNextLaneletIds(lanelet_id).empty()) {
LaneletPose lanelet_pose;
lanelet_pose.lanelet_id = lanelet_id;
lanelet_pose.s = pose::laneletLength(lanelet_id, hdmap_utils_ptr);
const auto pose = pose::toMapPose(lanelet_pose, hdmap_utils_ptr);
static constexpr double sink_radius = 1.0;
const auto traffic_sink_config = TrafficSinkConfig(
sink_radius, pose.position, auto_sink_entity_types, std::make_optional(lanelet_id));
addModule<TrafficSink>(entity_manager_ptr, traffic_sink_config);
addModule<TrafficSink>(entity_manager_ptr_, traffic_sink_config);
}
}
}

void TrafficController::execute(const double current_time, const double step_time)
auto TrafficController::execute(const double current_time, const double step_time) -> void
{
for (const auto & module : modules_) {
module->execute(current_time, step_time);
}
}

auto TrafficController::makeDebugMarker() const -> const visualization_msgs::msg::MarkerArray
auto TrafficController::makeDebugMarker() const -> visualization_msgs::msg::MarkerArray
{
static const auto marker_array = [&]() {
static const auto marker_array = [this]() {
visualization_msgs::msg::MarkerArray marker_array;
for (size_t i = 0UL; i < modules_.size(); ++i) {
for (std::size_t i = 0UL; i < modules_.size(); ++i) {
modules_[i]->appendDebugMarker(marker_array);
}
return marker_array;
Expand Down
Loading