forked from autowarefoundation/autoware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add external adaptor for cpu usage topic (autowarefoundation#19)
* add external adaptor for cpu usage topic Signed-off-by: TakumiKozaka-T4 <takumi.kozaka@tier4.jp> * run pre-commit Signed-off-by: TakumiKozaka-T4 <takumi.kozaka@tier4.jp> * modified along the comment on PR Signed-off-by: TakumiKozaka-T4 <takumi.kozaka@tier4.jp> * modify a comment Signed-off-by: TakumiKozaka-T4 <takumi.kozaka@tier4.jp>
- Loading branch information
1 parent
f72bb18
commit a187a54
Showing
3 changed files
with
77 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
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 2021 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 "cpu_usage.hpp" | ||
|
||
#include <memory> | ||
|
||
namespace external_api | ||
{ | ||
|
||
CpuUsage::CpuUsage(const rclcpp::NodeOptions & options) : Node("cpu_usage", options) | ||
{ | ||
pub_cpu_usage_ = create_publisher<tier4_external_api_msgs::msg::CpuUsage>( | ||
"/api/external/get/cpu_usage", rclcpp::QoS(1)); | ||
sub_cpu_usage_ = create_subscription<tier4_external_api_msgs::msg::CpuUsage>( | ||
"/system/system_monitor/cpu_monitor/cpu_usage", rclcpp::QoS(1), | ||
[this](const tier4_external_api_msgs::msg::CpuUsage::SharedPtr msg) { | ||
pub_cpu_usage_->publish(*msg); | ||
}); | ||
} | ||
|
||
} // namespace external_api | ||
|
||
#include "rclcpp_components/register_node_macro.hpp" | ||
RCLCPP_COMPONENTS_REGISTER_NODE(external_api::CpuUsage) |
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,39 @@ | ||
// Copyright 2021 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 CPU_USAGE_HPP_ | ||
#define CPU_USAGE_HPP_ | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "tier4_api_utils/tier4_api_utils.hpp" | ||
|
||
#include "tier4_external_api_msgs/msg/cpu_status.hpp" | ||
#include "tier4_external_api_msgs/msg/cpu_usage.hpp" | ||
|
||
namespace external_api | ||
{ | ||
|
||
class CpuUsage : public rclcpp::Node | ||
{ | ||
public: | ||
explicit CpuUsage(const rclcpp::NodeOptions & options); | ||
|
||
private: | ||
rclcpp::Publisher<tier4_external_api_msgs::msg::CpuUsage>::SharedPtr pub_cpu_usage_; | ||
rclcpp::Subscription<tier4_external_api_msgs::msg::CpuUsage>::SharedPtr sub_cpu_usage_; | ||
}; | ||
|
||
} // namespace external_api | ||
|
||
#endif // CPU_USAGE_HPP_ |