-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autoware_node): add AutowareNode base class
Signed-off-by: M. Fatih Cırıt <[email protected]>
- Loading branch information
M. Fatih Cırıt
committed
Jan 12, 2023
1 parent
6bafedf
commit df7e483
Showing
30 changed files
with
661 additions
and
0 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
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.
41 changes: 41 additions & 0 deletions
41
common/autoware_control_center/include/autoware_control_center/autoware_control_center.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,41 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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" | ||
|
||
#include "autoware_control_center_msgs/msg/autoware_control_center_json.hpp" | ||
|
||
namespace autoware_control_center | ||
{ | ||
|
||
class AutowareControlCenter : public rclcpp_lifecycle::LifecycleNode | ||
{ | ||
public: | ||
AutowareControlCenter(const rclcpp::NodeOptions & options); | ||
|
||
private: | ||
using AutowareControlCenterJson = autoware_control_center_msgs::msg::AutowareControlCenterJson; | ||
rclcpp::Subscription<AutowareControlCenterJson>::SharedPtr sub_global_; | ||
|
||
void callback_acc_json_global(const AutowareControlCenterJson::ConstSharedPtr & msg); | ||
}; | ||
|
||
} // namespace autoware_control_center | ||
|
||
#endif // AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_ |
28 changes: 28 additions & 0 deletions
28
common/autoware_control_center/include/autoware_control_center/visibility_control.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,28 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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_ |
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,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="[email protected]">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> |
34 changes: 34 additions & 0 deletions
34
common/autoware_control_center/src/autoware_control_center.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,34 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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"); | ||
} | ||
|
||
void AutowareControlCenter::callback_acc_json_global( | ||
const autoware_control_center_msgs::msg::AutowareControlCenterJson::ConstSharedPtr & msg) | ||
{ | ||
// log message | ||
RCLCPP_INFO(get_logger(), "AutowareControlCenterJson received %s", msg->json_message.c_str()); | ||
} | ||
|
||
} // namespace autoware_control_center |
36 changes: 36 additions & 0 deletions
36
common/autoware_control_center/src/autoware_control_center_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,36 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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) |
16 changes: 16 additions & 0 deletions
16
common/autoware_control_center/test/test_autoware_control_center.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,16 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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" |
23 changes: 23 additions & 0 deletions
23
common/autoware_control_center/test/test_autoware_control_center.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,23 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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_ |
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,15 @@ | ||
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} | ||
ADD_LINTER_TESTS) | ||
|
||
ament_auto_package() |
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 @@ | ||
# autoware_msgs | ||
|
||
Before contributing, review [the message guidelines](https://autowarefoundation.github.io/autoware-documentation/main/contributing/coding-guidelines/ros-nodes/message-guidelines/). |
6 changes: 6 additions & 0 deletions
6
common/autoware_control_center_msgs/msg/StatusRegistration.msg
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,6 @@ | ||
# Status States | ||
uint8 FAILURE=0 | ||
uint8 SUCCESS=1 | ||
|
||
# Status | ||
uint8 status |
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,23 @@ | ||
<?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="[email protected]">M. Fatih Cırıt</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
|
||
<depend>rosidl_default_generators</depend> | ||
<depend>unique_identifier_msgs</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
17 changes: 17 additions & 0 deletions
17
common/autoware_control_center_msgs/srv/AutowareNodeRegister.srv
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,17 @@ | ||
# Request | ||
|
||
## Name of the registering AutowareNode | ||
string name_node | ||
|
||
--- | ||
|
||
# Response | ||
|
||
## Status | ||
autoware_control_center_msgs/StatusRegistration status | ||
|
||
## UUID | ||
unique_identifier_msgs/UUID uuid_node | ||
|
||
## Response Log | ||
string log_response |
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,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.
42 changes: 42 additions & 0 deletions
42
common/autoware_node/include/autoware_node/autoware_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,42 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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" | ||
|
||
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_ |
27 changes: 27 additions & 0 deletions
27
common/autoware_node/include/autoware_node/visibility_control.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,27 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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_ |
Oops, something went wrong.