Skip to content

Commit 21ed897

Browse files
committed
feat(dummy_gear_cmd_publisher): add dummy gear cmd publisher
Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com>
1 parent 324dd24 commit 21ed897

7 files changed

+191
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(dummy_gear_cmd_publisher)
3+
4+
find_package(autoware_cmake REQUIRED)
5+
autoware_package()
6+
7+
ament_auto_add_library(dummy_gear_cmd_publisher SHARED
8+
src/dummy_gear_cmd_publisher.cpp
9+
)
10+
ament_target_dependencies(dummy_gear_cmd_publisher)
11+
12+
rclcpp_components_register_node(${PROJECT_NAME}
13+
PLUGIN "dummy_gear_cmd_publisher::DummyGearCmdPublisher"
14+
EXECUTABLE ${PROJECT_NAME}_node
15+
)
16+
17+
ament_auto_package(
18+
INSTALL_TO_SHARE
19+
launch
20+
config
21+
)
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dummy Gear Cmd Publisher
2+
3+
## Purpose
4+
5+
## Inner-workings / Algorithms
6+
7+
## Inputs / Outputs
8+
9+
### Input
10+
11+
### Output
12+
13+
## Parameters
14+
15+
## Assumptions / Known limits
16+
17+
## (Optional) Error detection and handling
18+
19+
## (Optional) Performance characterization
20+
21+
## (Optional) References/External links
22+
23+
## (Optional) Future extensions / Unimplemented parts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/**:
2+
ros__parameters:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<launch>
2+
<arg name="dummy_gear_cmd_publisher_param_path" default="$(find-pkg-share dummy_gear_cmd_publisher)/config/dummy_gear_cmd_publisher.param.yaml"/>
3+
4+
<node pkg="dummy_gear_cmd_publisher" exec="dummy_gear_cmd_publisher_node" name="dummy_gear_cmd_publisher" output="screen">
5+
<remap from="~/output/gear_cmd" to="/control/command/gear_cmd"/>
6+
</node>
7+
</launch>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>dummy_gear_cmd_publisher</name>
5+
<version>0.1.0</version>
6+
<description>The dummy_gear_cmd_publisher package</description>
7+
<maintainer email="makoto.kurihara@tier4.jp">Makoto Kurihara</maintainer>
8+
<license>Apache License 2.0</license>
9+
10+
<buildtool_depend>ament_cmake_auto</buildtool_depend>
11+
12+
<build_depend>autoware_cmake</build_depend>
13+
14+
<!-- depend -->
15+
<depend>autoware_auto_vehicle_msgs</depend>
16+
<depend>rclcpp</depend>
17+
<depend>rclcpp_components</depend>
18+
19+
<test_depend>ament_lint_auto</test_depend>
20+
<test_depend>autoware_lint_common</test_depend>
21+
22+
<export>
23+
<build_type>ament_cmake</build_type>
24+
</export>
25+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2024 TIER IV, Inc.
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 "dummy_gear_cmd_publisher.hpp"
16+
17+
namespace dummy_gear_cmd_publisher
18+
{
19+
20+
DummyGearCmdPublisher::DummyGearCmdPublisher(const rclcpp::NodeOptions & node_options)
21+
: Node("dummy_gear_cmd_publisher", node_options)
22+
{
23+
// Parameter
24+
25+
// Subscriber
26+
27+
// Publisher
28+
pub_gear_cmd_ = create_publisher<autoware_auto_vehicle_msgs::msg::GearCommand>(
29+
"~/output/gear_cmd", 10);
30+
31+
// Service
32+
33+
// Client
34+
35+
// Timer
36+
using namespace std::literals::chrono_literals;
37+
timer_ = rclcpp::create_timer(
38+
this, get_clock(), 1s, std::bind(&DummyGearCmdPublisher::onTimer, this));
39+
40+
// State
41+
42+
// Diagnostics
43+
44+
}
45+
46+
void DummyGearCmdPublisher::onTimer()
47+
{
48+
autoware_auto_vehicle_msgs::msg::GearCommand msg;
49+
msg.stamp = this->now();
50+
msg.command = autoware_auto_vehicle_msgs::msg::GearCommand::DRIVE;
51+
52+
pub_gear_cmd_->publish(msg);
53+
}
54+
55+
} // namespace dummy_gear_cmd_publisher
56+
57+
#include <rclcpp_components/register_node_macro.hpp>
58+
RCLCPP_COMPONENTS_REGISTER_NODE(dummy_gear_cmd_publisher::DummyGearCmdPublisher)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2024 TIER IV, Inc.
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+
#ifndef DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_
16+
#define DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_
17+
18+
// include
19+
#include <autoware_auto_vehicle_msgs/msg/gear_command.hpp>
20+
#include <rclcpp/rclcpp.hpp>
21+
22+
namespace dummy_gear_cmd_publisher
23+
{
24+
25+
class DummyGearCmdPublisher : public rclcpp::Node
26+
{
27+
public:
28+
explicit DummyGearCmdPublisher(const rclcpp::NodeOptions & node_options);
29+
~DummyGearCmdPublisher() = default;
30+
31+
private:
32+
// Parameter
33+
34+
// Subscriber
35+
36+
// Publisher
37+
rclcpp::Publisher<autoware_auto_vehicle_msgs::msg::GearCommand>::SharedPtr pub_gear_cmd_;
38+
39+
// Service
40+
41+
// Client
42+
43+
// Timer
44+
rclcpp::TimerBase::SharedPtr timer_;
45+
46+
void onTimer();
47+
48+
// State
49+
50+
// Diagnostics
51+
52+
};
53+
} // namespace dummy_gear_cmd_publisher
54+
55+
#endif // DUMMY_GEAR_CMD_PUBLISHER__DUMMY_GEAR_CMD_PUBLISHER_HPP_

0 commit comments

Comments
 (0)