Skip to content

Commit 0fe3742

Browse files
author
Vortex
committed
add string debug publisher for mode and killswitch
1 parent 0fcaa8c commit 0fe3742

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

mission/operation_mode_manager/include/operation_mode_manager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <geometry_msgs/msg/wrench_stamped.hpp>
77
#include <rclcpp/rclcpp.hpp>
88
#include <std_msgs/msg/bool.hpp>
9+
#include <std_msgs/msg/string.hpp>
910

1011
#include <vortex/utils/types.hpp>
1112
#include <vortex_msgs/msg/operation_mode.hpp>
@@ -47,6 +48,8 @@ class OperationModeManager : public rclcpp::Node {
4748
rclcpp::Publisher<geometry_msgs::msg::WrenchStamped>::SharedPtr wrench_pub_;
4849
rclcpp::Publisher<std_msgs::msg::Bool>::SharedPtr killswitch_pub_;
4950
rclcpp::Publisher<vortex_msgs::msg::OperationMode>::SharedPtr mode_pub_;
51+
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr killswitch_string_pub_;
52+
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr mode_string_pub_;
5053

5154
rclcpp::Service<vortex_msgs::srv::SetOperationMode>::SharedPtr
5255
set_operation_mode_service_;

mission/operation_mode_manager/src/operation_mode_manager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ void OperationModeManager::setup_publishers() {
4141
this->get_parameter("topics.killswitch").as_string();
4242
const auto operation_mode_topic =
4343
this->get_parameter("topics.operation_mode").as_string();
44+
const auto killswitch_string_topic = killswitch_topic + "_string";
45+
const auto operation_mode_string_topic = operation_mode_topic + "_string";
4446

4547
wrench_pub_ = this->create_publisher<geometry_msgs::msg::WrenchStamped>(
4648
wrench_input_topic,
@@ -51,6 +53,14 @@ void OperationModeManager::setup_publishers() {
5153

5254
mode_pub_ = this->create_publisher<vortex_msgs::msg::OperationMode>(
5355
operation_mode_topic, vortex::utils::qos_profiles::reliable_profile(1));
56+
57+
killswitch_string_pub_ = this->create_publisher<std_msgs::msg::String>(
58+
killswitch_string_topic,
59+
vortex::utils::qos_profiles::reliable_profile(1));
60+
61+
mode_string_pub_ = this->create_publisher<std_msgs::msg::String>(
62+
operation_mode_string_topic,
63+
vortex::utils::qos_profiles::reliable_profile(1));
5464
}
5565

5666
void OperationModeManager::setup_services() {
@@ -152,6 +162,14 @@ void OperationModeManager::publish_mode() {
152162
std_msgs::msg::Bool killswitch_msg;
153163
killswitch_msg.data = killswitch_;
154164
killswitch_pub_->publish(killswitch_msg);
165+
166+
std_msgs::msg::String killswitch_string_msg;
167+
killswitch_string_msg.data = "killswitch: " + std::string(killswitch_ ? "true" : "false");
168+
killswitch_string_pub_->publish(killswitch_string_msg);
169+
170+
std_msgs::msg::String mode_string_msg;
171+
mode_string_msg.data = "mode: " + vortex::utils::types::mode_to_string(mode_);
172+
mode_string_pub_->publish(mode_string_msg);
155173
}
156174

157175
void OperationModeManager::publish_empty_wrench() {

0 commit comments

Comments
 (0)