From 5a0a7f44c08de5b91095d886610eff285b1d50d8 Mon Sep 17 00:00:00 2001 From: TetsuKawa Date: Fri, 6 Dec 2024 20:48:50 +0900 Subject: [PATCH] feat: add dummy gear cmd publisher Signed-off-by: TetsuKawa --- dummy/dummy_gear_cmd_publisher/CMakeLists.txt | 21 +++++++ dummy/dummy_gear_cmd_publisher/README.md | 23 ++++++++ .../dummy_gear_cmd_publisher.param.yaml | 2 + .../dummy_gear_cmd_publisher.launch.xml | 7 +++ dummy/dummy_gear_cmd_publisher/package.xml | 25 ++++++++ .../src/dummy_gear_cmd_publisher.cpp | 58 +++++++++++++++++++ .../src/dummy_gear_cmd_publisher.hpp | 55 ++++++++++++++++++ 7 files changed, 191 insertions(+) create mode 100644 dummy/dummy_gear_cmd_publisher/CMakeLists.txt create mode 100644 dummy/dummy_gear_cmd_publisher/README.md create mode 100644 dummy/dummy_gear_cmd_publisher/config/dummy_gear_cmd_publisher.param.yaml create mode 100644 dummy/dummy_gear_cmd_publisher/launch/dummy_gear_cmd_publisher.launch.xml create mode 100644 dummy/dummy_gear_cmd_publisher/package.xml create mode 100644 dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.cpp create mode 100644 dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.hpp diff --git a/dummy/dummy_gear_cmd_publisher/CMakeLists.txt b/dummy/dummy_gear_cmd_publisher/CMakeLists.txt new file mode 100644 index 0000000000000..40d07b77d6a22 --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.14) +project(dummy_gear_cmd_publisher) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +ament_auto_add_library(dummy_gear_cmd_publisher SHARED + src/dummy_gear_cmd_publisher.cpp +) +ament_target_dependencies(dummy_gear_cmd_publisher) + +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "dummy_gear_cmd_publisher::DummyGearCmdPublisher" + EXECUTABLE ${PROJECT_NAME}_node +) + +ament_auto_package( + INSTALL_TO_SHARE + launch + config +) diff --git a/dummy/dummy_gear_cmd_publisher/README.md b/dummy/dummy_gear_cmd_publisher/README.md new file mode 100644 index 0000000000000..46a9957bc3760 --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/README.md @@ -0,0 +1,23 @@ +# Dummy Gear Cmd Publisher + +## Purpose + +## Inner-workings / Algorithms + +## Inputs / Outputs + +### Input + +### Output + +## Parameters + +## Assumptions / Known limits + +## (Optional) Error detection and handling + +## (Optional) Performance characterization + +## (Optional) References/External links + +## (Optional) Future extensions / Unimplemented parts diff --git a/dummy/dummy_gear_cmd_publisher/config/dummy_gear_cmd_publisher.param.yaml b/dummy/dummy_gear_cmd_publisher/config/dummy_gear_cmd_publisher.param.yaml new file mode 100644 index 0000000000000..a20dbd7ffd3d9 --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/config/dummy_gear_cmd_publisher.param.yaml @@ -0,0 +1,2 @@ +/**: + ros__parameters: diff --git a/dummy/dummy_gear_cmd_publisher/launch/dummy_gear_cmd_publisher.launch.xml b/dummy/dummy_gear_cmd_publisher/launch/dummy_gear_cmd_publisher.launch.xml new file mode 100644 index 0000000000000..8d98f6035dd16 --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/launch/dummy_gear_cmd_publisher.launch.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dummy/dummy_gear_cmd_publisher/package.xml b/dummy/dummy_gear_cmd_publisher/package.xml new file mode 100644 index 0000000000000..7ef58f4d7bebf --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/package.xml @@ -0,0 +1,25 @@ + + + + dummy_gear_cmd_publisher + 0.1.0 + The dummy_gear_cmd_publisher package + Makoto Kurihara + Apache License 2.0 + + ament_cmake_auto + + autoware_cmake + + + autoware_auto_vehicle_msgs + rclcpp + rclcpp_components + + ament_lint_auto + autoware_lint_common + + + ament_cmake + + diff --git a/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.cpp b/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.cpp new file mode 100644 index 0000000000000..3ec06996423ee --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.cpp @@ -0,0 +1,58 @@ +// Copyright 2024 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 "dummy_gear_cmd_publisher.hpp" + +namespace dummy_gear_cmd_publisher +{ + +DummyGearCmdPublisher::DummyGearCmdPublisher(const rclcpp::NodeOptions & node_options) +: Node("dummy_gear_cmd_publisher", node_options) +{ + // Parameter + + // Subscriber + + // Publisher + pub_gear_cmd_ = create_publisher( + "~/output/gear_cmd", 10); + + // Service + + // Client + + // Timer + using namespace std::literals::chrono_literals; + timer_ = rclcpp::create_timer( + this, get_clock(), 1s, std::bind(&DummyGearCmdPublisher::onTimer, this)); + + // State + + // Diagnostics + +} + +void DummyGearCmdPublisher::onTimer() +{ + autoware_auto_vehicle_msgs::msg::GearCommand msg; + msg.stamp = this->now(); + msg.command = autoware_auto_vehicle_msgs::msg::GearCommand::DRIVE; + + pub_gear_cmd_->publish(msg); +} + +} // namespace dummy_gear_cmd_publisher + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(dummy_gear_cmd_publisher::DummyGearCmdPublisher) diff --git a/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.hpp b/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.hpp new file mode 100644 index 0000000000000..4ac317d8fa479 --- /dev/null +++ b/dummy/dummy_gear_cmd_publisher/src/dummy_gear_cmd_publisher.hpp @@ -0,0 +1,55 @@ +// Copyright 2024 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 DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_ +#define DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_ + +// include +#include +#include + +namespace dummy_gear_cmd_publisher +{ + +class DummyGearCmdPublisher : public rclcpp::Node +{ +public: + explicit DummyGearCmdPublisher(const rclcpp::NodeOptions & node_options); + ~DummyGearCmdPublisher() = default; + +private: + // Parameter + + // Subscriber + + // Publisher + rclcpp::Publisher::SharedPtr pub_gear_cmd_; + + // Service + + // Client + + // Timer + rclcpp::TimerBase::SharedPtr timer_; + + void onTimer(); + + // State + + // Diagnostics + +}; +} // namespace dummy_gear_cmd_publisher + +#endif // DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_