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

feat(autoware_node): add AutowareNode base class #57

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions common/autoware_control_center/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.8)
project(autoware_control_center)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

autoware_package()

ament_auto_add_executable(${PROJECT_NAME} src/autoware_control_center_node.cpp
src/autoware_control_center.cpp)
#target_link_libraries(${PROJECT_NAME})

#if (BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# ament_lint_auto_find_test_dependencies()
# ament_add_ros_isolated_gtest(test_autoware_control_center test/test_autoware_control_center.cpp)
# target_link_libraries(test_autoware_control_center ${PROJECT_NAME})
#endif ()

ament_auto_package()
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2022 The Autoware Contributors
//
// 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 AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_
#define AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_

#include "autoware_control_center/visibility_control.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"

namespace autoware_control_center
{

class AutowareControlCenter : public rclcpp_lifecycle::LifecycleNode
{
public:
explicit AutowareControlCenter(const rclcpp::NodeOptions & options);

private:
};

} // namespace autoware_control_center

#endif // AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2022 The Autoware Contributors
//
// 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 AUTOWARE_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_
#define AUTOWARE_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_

#include "rcutils/visibility_control_macros.h"

#ifdef AUTOWARE_CONTROL_CENTER_BUILDING_DLL
#define AUTOWARE_CONTROL_CENTER_PUBLIC RCUTILS_EXPORT
#else
#define AUTOWARE_CONTROL_CENTER_PUBLIC RCUTILS_IMPORT
#endif // !AUTOWARE_CONTROL_CENTER_BUILDING_DLL
#define AUTOWARE_CONTROL_CENTER_LOCAL RCUTILS_LOCAL

#endif // AUTOWARE_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_
29 changes: 29 additions & 0 deletions common/autoware_control_center/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>autoware_control_center</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="mfc@leodrive.ai">M. Fatih Cırıt</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_control_center_msgs</depend>
<depend>bond</depend>
<depend>bondcpp</depend>
<depend>lifecycle_msgs</depend>
<depend>nlohmann-json-dev</depend>
<depend>rclcpp_components</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rcutils</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
26 changes: 26 additions & 0 deletions common/autoware_control_center/src/autoware_control_center.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2022 The Autoware Contributors
//
// 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 "autoware_control_center/autoware_control_center.hpp"

namespace autoware_control_center
{
AutowareControlCenter::AutowareControlCenter(const rclcpp::NodeOptions & options)
: LifecycleNode("autoware_control_center", options)
{
// log info
RCLCPP_INFO(get_logger(), "AutowareControlCenter is initialized");
}

} // namespace autoware_control_center
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2022 The Autoware Contributors
//
// 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 "autoware_control_center/autoware_control_center.hpp"

#include <rclcpp/rclcpp.hpp>

#include <memory>

int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
auto autoware_control_center =
std::make_shared<autoware_control_center::AutowareControlCenter>(rclcpp::NodeOptions());
rclcpp::executors::MultiThreadedExecutor exec;
exec.add_node(autoware_control_center->get_node_base_interface());
exec.spin();
rclcpp::shutdown();

return 0;
}

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(autoware_control_center::AutowareControlCenter)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2022 The Autoware Contributors
//
// 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 "test_autoware_control_center.hpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2022 The Autoware Contributors
//
// 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 TEST_AUTOWARE_CONTROL_CENTER_HPP_
#define TEST_AUTOWARE_CONTROL_CENTER_HPP_

class test_autoware_control_center
{
};

#endif // TEST_AUTOWARE_CONTROL_CENTER_HPP_
20 changes: 20 additions & 0 deletions common/autoware_control_center_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_control_center_msgs)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

set(msg_dependencies
unique_identifier_msgs)

rosidl_generate_interfaces(${PROJECT_NAME}
"msg/StatusRegistration.msg"
"srv/AutowareNodeRegister.srv"
DEPENDENCIES ${msg_dependencies})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package()
3 changes: 3 additions & 0 deletions common/autoware_control_center_msgs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# autoware_msgs

Before contributing, review [the message guidelines](https://autowarefoundation.github.io/autoware-documentation/main/contributing/coding-guidelines/ros-nodes/message-guidelines/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Status States
uint8 FAILURE=0
uint8 SUCCESS=1

# Status
uint8 status
26 changes: 26 additions & 0 deletions common/autoware_control_center_msgs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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>autoware_control_center_msgs</name>
<version>1.0.0</version>
<description>autoware_control_center_msgs package.</description>
<maintainer email="mfc@leodrive.ai">M. Fatih Cırıt</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<build_depend>rosidl_default_generators</build_depend>

<depend>unique_identifier_msgs</depend>

<exec_depend>rosidl_default_runtime</exec_depend>

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

<member_of_group>rosidl_interface_packages</member_of_group>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
string name_node
---
autoware_control_center_msgs/StatusRegistration status
unique_identifier_msgs/UUID uuid_node
string log_response
18 changes: 18 additions & 0 deletions common/autoware_node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.8)
project(autoware_node)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

autoware_package()

ament_auto_add_library(${PROJECT_NAME} src/autoware_node.cpp)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
ament_add_ros_isolated_gtest(test_autoware_node test/test_autoware_node.cpp)
target_link_libraries(test_autoware_node ${PROJECT_NAME})
endif()

ament_auto_package()
Empty file added common/autoware_node/README.md
Empty file.
43 changes: 43 additions & 0 deletions common/autoware_node/include/autoware_node/autoware_node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2022 The Autoware Contributors
//
// 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 AUTOWARE_NODE__AUTOWARE_NODE_HPP_
#define AUTOWARE_NODE__AUTOWARE_NODE_HPP_

#include "autoware_node/visibility_control.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"

#include "autoware_control_center_msgs/srv/autoware_node_register.hpp"

#include <string>

namespace autoware_node
{

class AutowareNode : public rclcpp_lifecycle::LifecycleNode
{
public:
AUTOWARE_NODE_PUBLIC
AutowareNode(
const std::string & node_name, const std::string & ns = "",
const rclcpp::NodeOptions & options = rclcpp::NodeOptions());

rclcpp::CallbackGroup::SharedPtr callback_group_mut_ex_;

rclcpp::Client<autoware_control_center_msgs::srv::AutowareNodeRegister>::SharedPtr cli_register_;
};

} // namespace autoware_node

#endif // AUTOWARE_NODE__AUTOWARE_NODE_HPP_
26 changes: 26 additions & 0 deletions common/autoware_node/include/autoware_node/visibility_control.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2022 The Autoware Contributors
//
// 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 AUTOWARE_NODE__VISIBILITY_CONTROL_HPP_
#define AUTOWARE_NODE__VISIBILITY_CONTROL_HPP_

#include "rcutils/visibility_control_macros.h"
#ifdef AUTOWARE_NODE_BUILDING_DLL
#define AUTOWARE_NODE_PUBLIC RCUTILS_EXPORT
#else
#define AUTOWARE_NODE_PUBLIC RCUTILS_IMPORT
#endif // !AUTOWARE_NODE_BUILDING_DLL
#define AUTOWARE_NODE_LOCAL RCUTILS_LOCAL

#endif // AUTOWARE_NODE__VISIBILITY_CONTROL_HPP_
25 changes: 25 additions & 0 deletions common/autoware_node/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>autoware_node</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="mfc@leodrive.ai">M. Fatih Cırıt</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_control_center_msgs</depend>
<depend>nlohmann-json-dev</depend>
<depend>rclcpp_lifecycle</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>autoware_control_center</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading