forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hazard_lights_selector): add hazard_lights_selector (#1157)
* feat(hazard_lights_selector): turn on hazard lights from mrm comfortable stop operator (#323) * chore(hazard_lights_selector): add the hazard_lights_selector package Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * chore(hazard_lights_selector): implement a header file Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * chore(hazard_lights_selector): implement the hazard_lights_selector package Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * chore(hazard_lights_selector): remove a current hazard lights command state Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * refacotr(hazard_lights_selector): remove extra lines Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * feat(mrm_comfortable_stop_operator): add hazard lights publisher Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * chore(hazard_lights_selector): add a maintainer Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * style: pre-commit fixes Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> --------- Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> Co-authored-by: Tomohito Ando <tomohito.ando@tier4.jp> * migrate to latest Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp> --------- Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp> Co-authored-by: Makoto Kurihara <mkuri8m@gmail.com> Co-authored-by: Tomohito Ando <tomohito.ando@tier4.jp>
- Loading branch information
1 parent
9133ea1
commit f173fad
Showing
13 changed files
with
321 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(hazard_lights_selector) | ||
|
||
find_package(autoware_cmake REQUIRED) | ||
autoware_package() | ||
|
||
ament_auto_add_library(hazard_lights_selector_node SHARED | ||
src/hazard_lights_selector_node.cpp | ||
) | ||
|
||
rclcpp_components_register_node(hazard_lights_selector_node | ||
PLUGIN "hazard_lights_selector::HazardLightsSelectorNode" | ||
EXECUTABLE hazard_lights_selector | ||
) | ||
|
||
ament_auto_package(INSTALL_TO_SHARE | ||
launch | ||
config | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Hazard lights selector | ||
|
||
## Purpose | ||
|
||
## Inner-workings / Algorithms | ||
|
||
<!-- Write how this package works. Flowcharts and figures are great. Add sub-sections as you like. | ||
Example: | ||
### Flowcharts | ||
...(PlantUML or something) | ||
### State Transitions | ||
...(PlantUML or something) | ||
### How to filter target obstacles | ||
... | ||
### How to optimize trajectory | ||
... | ||
--> | ||
|
||
## Inputs | ||
|
||
## Outputs | ||
|
||
## Parameters | ||
|
||
## Assumptions / Known limits | ||
|
||
<!-- Write assumptions and limitations of your implementation. | ||
Example: | ||
This algorithm assumes obstacles are not moving, so if they rapidly move after the vehicle started to avoid them, it might collide with them. | ||
Also, this algorithm doesn't care about blind spots. In general, since too close obstacles aren't visible due to the sensing performance limit, please take enough margin to obstacles. | ||
--> | ||
|
||
## (Optional) Error detection and handling | ||
|
||
<!-- Write how to detect errors and how to recover from them. | ||
Example: | ||
This package can handle up to 20 obstacles. If more obstacles found, this node will give up and raise diagnostic errors. | ||
--> | ||
|
||
## (Optional) Performance characterization | ||
|
||
<!-- Write performance information like complexity. If it wouldn't be the bottleneck, not necessary. | ||
Example: | ||
### Complexity | ||
This algorithm is O(N). | ||
### Processing time | ||
... | ||
--> | ||
|
||
## (Optional) References/External links | ||
|
||
<!-- Write links you referred to when you implemented. | ||
Example: | ||
[1] {link_to_a_thesis} | ||
[2] {link_to_an_issue} | ||
--> | ||
|
||
## (Optional) Future extensions / Unimplemented parts | ||
|
||
<!-- Write future extensions of this package. | ||
Example: | ||
Currently, this package can't handle the chattering obstacles well. We plan to add some probabilistic filters in the perception layer to improve it. | ||
Also, there are some parameters that should be global(e.g. vehicle size, max steering, etc.). These will be refactored and defined as global parameters so that we can share the same parameters between different nodes. | ||
--> |
3 changes: 3 additions & 0 deletions
3
system/hazard_lights_selector/config/hazard_lights_selector.param.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/**: | ||
ros__parameters: | ||
update_rate: 10 # hazard lights command publish rate [Hz] |
63 changes: 63 additions & 0 deletions
63
system/hazard_lights_selector/include/hazard_lights_selector/hazard_lights_selector_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2021 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. | ||
|
||
#ifndef HAZARD_LIGHTS_SELECTOR__HAZARD_LIGHTS_SELECTOR_NODE_HPP_ | ||
#define HAZARD_LIGHTS_SELECTOR__HAZARD_LIGHTS_SELECTOR_NODE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <autoware_auto_vehicle_msgs/msg/hazard_lights_command.hpp> | ||
|
||
namespace hazard_lights_selector | ||
{ | ||
using autoware_auto_vehicle_msgs::msg::HazardLightsCommand; | ||
|
||
class HazardLightsSelectorNode : public rclcpp::Node | ||
{ | ||
struct Parameters | ||
{ | ||
int update_rate; // [Hz] | ||
}; | ||
|
||
public: | ||
explicit HazardLightsSelectorNode(const rclcpp::NodeOptions & node_options); | ||
|
||
private: | ||
// Parameter | ||
Parameters params_; | ||
|
||
// Subscriber | ||
rclcpp::Subscription<HazardLightsCommand>::SharedPtr sub_hazard_lights_cmd_from_path_planner_; | ||
rclcpp::Subscription<HazardLightsCommand>::SharedPtr sub_hazard_lights_cmd_from_mrm_operator_; | ||
|
||
void onHazardLightsCommandFromPathPlanner(HazardLightsCommand::ConstSharedPtr msg); | ||
void onHazardLightsCommandFromMrmOperator(HazardLightsCommand::ConstSharedPtr msg); | ||
|
||
// Publisher | ||
rclcpp::Publisher<HazardLightsCommand>::SharedPtr pub_hazard_lights_cmd_; | ||
|
||
void publishHazardLightsCommand() const; | ||
|
||
// Timer | ||
rclcpp::TimerBase::SharedPtr timer_; | ||
|
||
void onTimer(); | ||
|
||
// State | ||
HazardLightsCommand::ConstSharedPtr hazard_lights_command_from_path_planner_; | ||
HazardLightsCommand::ConstSharedPtr hazard_lights_command_from_mrm_operator_; | ||
}; | ||
} // namespace hazard_lights_selector | ||
|
||
#endif // HAZARD_LIGHTS_SELECTOR__HAZARD_LIGHTS_SELECTOR_NODE_HPP_ |
16 changes: 16 additions & 0 deletions
16
system/hazard_lights_selector/launch/hazard_lights_selector.launch.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<launch> | ||
<!-- common param --> | ||
<arg name="param_path" default="$(find-pkg-share hazard_lights_selector)/config/hazard_lights_selector.param.yaml"/> | ||
|
||
<!-- input/output --> | ||
<arg name="input_hazard_lights_cmd_from_path_planner" default="/planning/behavior_path_planner/hazard_lights_cmd"/> | ||
<arg name="input_hazard_lights_cmd_from_mrm_operator" default="/system/mrm_comfortable_stop_operator/hazard_lights_cmd"/> | ||
<arg name="output_hazard_lights_cmd" default="/planning/hazard_lights_cmd"/> | ||
|
||
<node pkg="hazard_lights_selector" exec="hazard_lights_selector" name="hazard_lights_selector" output="screen"> | ||
<param from="$(var param_path)"/> | ||
<remap from="~/input/behavior_path_planner/hazard_lights_cmd" to="$(var input_hazard_lights_cmd_from_path_planner)"/> | ||
<remap from="~/input/behavior_mrm_operator/hazard_lights_cmd" to="$(var input_hazard_lights_cmd_from_mrm_operator)"/> | ||
<remap from="~/output/hazard_lights_cmd" to="$(var output_hazard_lights_cmd)"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>hazard_lights_selector</name> | ||
<version>0.1.0</version> | ||
<description>The hazard_lights_selector ROS2 package</description> | ||
<maintainer email="makoto.kurihara@tier4.jp">Makoto Kurihara</maintainer> | ||
<maintainer email="tomohito.ando@tier4.jp">Tomohito Ando</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<author email="makoto.kurihara@tier4.jp">Makoto Kurihara</author> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
|
||
<build_depend>autoware_cmake</build_depend> | ||
|
||
<depend>autoware_auto_vehicle_msgs</depend> | ||
<depend>rclcpp</depend> | ||
<depend>rclcpp_components</depend> | ||
|
||
<exec_depend>ros2cli</exec_depend> | ||
<exec_depend>topic_tools</exec_depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>autoware_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
80 changes: 80 additions & 0 deletions
80
system/hazard_lights_selector/src/hazard_lights_selector_node.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2021 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 <hazard_lights_selector/hazard_lights_selector_node.hpp> | ||
|
||
namespace hazard_lights_selector | ||
{ | ||
HazardLightsSelectorNode::HazardLightsSelectorNode(const rclcpp::NodeOptions & node_options) | ||
: Node("hazard_lights_selector", node_options) | ||
{ | ||
using std::placeholders::_1; | ||
|
||
// Parameter | ||
params_.update_rate = static_cast<int>(declare_parameter<int>("update_rate", 10)); | ||
|
||
// Subscriber | ||
sub_hazard_lights_cmd_from_path_planner_ = this->create_subscription<HazardLightsCommand>( | ||
"~/input/behavior_path_planner/hazard_lights_cmd", 1, | ||
std::bind(&HazardLightsSelectorNode::onHazardLightsCommandFromPathPlanner, this, _1)); | ||
sub_hazard_lights_cmd_from_mrm_operator_ = this->create_subscription<HazardLightsCommand>( | ||
"~/input/behavior_mrm_operator/hazard_lights_cmd", 1, | ||
std::bind(&HazardLightsSelectorNode::onHazardLightsCommandFromMrmOperator, this, _1)); | ||
|
||
// Publisher | ||
pub_hazard_lights_cmd_ = | ||
this->create_publisher<HazardLightsCommand>("~/output/hazard_lights_cmd", 1); | ||
|
||
// Timer | ||
const auto update_period_ns = rclcpp::Rate(params_.update_rate).period(); | ||
timer_ = rclcpp::create_timer( | ||
this, get_clock(), update_period_ns, std::bind(&HazardLightsSelectorNode::onTimer, this)); | ||
} | ||
|
||
void HazardLightsSelectorNode::onHazardLightsCommandFromPathPlanner( | ||
HazardLightsCommand::ConstSharedPtr msg) | ||
{ | ||
hazard_lights_command_from_path_planner_ = msg; | ||
} | ||
|
||
void HazardLightsSelectorNode::onHazardLightsCommandFromMrmOperator( | ||
HazardLightsCommand::ConstSharedPtr msg) | ||
{ | ||
hazard_lights_command_from_mrm_operator_ = msg; | ||
} | ||
|
||
void HazardLightsSelectorNode::onTimer() | ||
{ | ||
auto hazard_lights_cmd = HazardLightsCommand(); | ||
hazard_lights_cmd.stamp = this->now(); | ||
hazard_lights_cmd.command = HazardLightsCommand::DISABLE; | ||
|
||
if (hazard_lights_command_from_path_planner_ != nullptr) { | ||
if (hazard_lights_command_from_path_planner_->command == HazardLightsCommand::ENABLE) { | ||
hazard_lights_cmd.command = HazardLightsCommand::ENABLE; | ||
} | ||
} | ||
if (hazard_lights_command_from_mrm_operator_ != nullptr) { | ||
if (hazard_lights_command_from_mrm_operator_->command == HazardLightsCommand::ENABLE) { | ||
hazard_lights_cmd.command = HazardLightsCommand::ENABLE; | ||
} | ||
} | ||
|
||
pub_hazard_lights_cmd_->publish(hazard_lights_cmd); | ||
} | ||
|
||
} // namespace hazard_lights_selector | ||
|
||
#include "rclcpp_components/register_node_macro.hpp" | ||
RCLCPP_COMPONENTS_REGISTER_NODE(hazard_lights_selector::HazardLightsSelectorNode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.