Skip to content

Commit

Permalink
feat(dummy_operation_mode_publisher): add dummy operation mode publis…
Browse files Browse the repository at this point in the history
…her (#1681)

feat: add dummy operation mode publisher

Signed-off-by: TetsuKawa <[email protected]>
  • Loading branch information
TetsuKawa authored Dec 6, 2024
1 parent 9c0467d commit a3417a6
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dummy/dummy_operation_mode_publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.14)
project(dummy_operation_mode_publisher)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_library(dummy_operation_mode_publisher SHARED
src/dummy_operation_mode_publisher.cpp
)
ament_target_dependencies(dummy_operation_mode_publisher)

rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "dummy_operation_mode_publisher::DummyOperationModePublisher"
EXECUTABLE ${PROJECT_NAME}_node
)

ament_auto_package(
INSTALL_TO_SHARE
launch
config
)
23 changes: 23 additions & 0 deletions dummy/dummy_operation_mode_publisher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dummy Operation Mode 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**:
ros__parameters:
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<launch>
<arg name="dummy_operation_mode_publisher_param_path" default="$(find-pkg-share dummy_operation_mode_publisher)/config/dummy_operation_mode_publisher.param.yaml"/>

<node pkg="dummy_operation_mode_publisher" exec="dummy_operation_mode_publisher_node" name="dummy_operation_mode_publisher" output="screen">
<remap from="~/output/operation_mode_state" to="/system/operation_mode/state"/>
<remap from="~/output/operation_mode_state_adapi" to="/api/operation_mode/state"/>
</node>
</launch>
25 changes: 25 additions & 0 deletions dummy/dummy_operation_mode_publisher/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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>dummy_operation_mode_publisher</name>
<version>0.1.0</version>
<description>The dummy_operation_mode_publisher package</description>
<maintainer email="[email protected]">Makoto Kurihara</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<build_depend>autoware_cmake</build_depend>

<!-- depend -->
<depend>autoware_adapi_v1_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// 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_operation_mode_publisher.hpp"

namespace dummy_operation_mode_publisher
{

DummyOperationModePublisher::DummyOperationModePublisher(const rclcpp::NodeOptions & node_options)
: Node("dummy_operation_mode_publisher", node_options)
{
// Parameter

// Subscriber

// Publisher
pub_operation_mode_state_ = create_publisher<autoware_adapi_v1_msgs::msg::OperationModeState>(
"~/output/operation_mode_state", 10);
pub_operation_mode_state_adapi_ =
create_publisher<autoware_adapi_v1_msgs::msg::OperationModeState>(
"~/output/operation_mode_state_adapi", 10);

// Service

// Client

// Timer
using namespace std::literals::chrono_literals;
timer_ = rclcpp::create_timer(
this, get_clock(), 1s, std::bind(&DummyOperationModePublisher::onTimer, this));

// State

// Diagnostics
}

void DummyOperationModePublisher::onTimer()
{
autoware_adapi_v1_msgs::msg::OperationModeState msg;
msg.stamp = this->now();
msg.mode = autoware_adapi_v1_msgs::msg::OperationModeState::AUTONOMOUS;
msg.is_autonomous_mode_available = true;
msg.is_in_transition = false;
msg.is_stop_mode_available = true;
msg.is_autonomous_mode_available = true;
msg.is_local_mode_available = true;
msg.is_remote_mode_available = true;

pub_operation_mode_state_->publish(msg);
pub_operation_mode_state_adapi_->publish(msg);
}

} // namespace dummy_operation_mode_publisher

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(dummy_operation_mode_publisher::DummyOperationModePublisher)
Original file line number Diff line number Diff line change
@@ -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.

#ifndef DUMMY_OPERATION_MODE_PUBLISHER_HPP_
#define DUMMY_OPERATION_MODE_PUBLISHER_HPP_

// include
#include <rclcpp/rclcpp.hpp>

#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>

namespace dummy_operation_mode_publisher
{

class DummyOperationModePublisher : public rclcpp::Node
{
public:
explicit DummyOperationModePublisher(const rclcpp::NodeOptions & node_options);
~DummyOperationModePublisher() = default;

private:
// Parameter

// Subscriber

// Publisher
rclcpp::Publisher<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr
pub_operation_mode_state_;
rclcpp::Publisher<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr
pub_operation_mode_state_adapi_;

// Service

// Client

// Timer
rclcpp::TimerBase::SharedPtr timer_;

void onTimer();

// State

// Diagnostics
};
} // namespace dummy_operation_mode_publisher

#endif // DUMMY_OPERATION_MODE_PUBLISHER_HPP_

0 comments on commit a3417a6

Please sign in to comment.