EtherCAT Control Framework v0.9
Implementation of EtherCAT protocol using IgH EtherCAT library for robot controller.
gui_node.hpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * $Id$
4 *
5 * Copyright (C) 2021 Veysi ADIN, UST KIST
6 *
7 * This file is part of the IgH EtherCAT master userspace program in the ROS2 environment.
8 *
9 * The IgH EtherCAT master userspace program in the ROS2 environment is free software; you can
10 * redistribute it and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software Foundation; version 2
12 * of the License.
13 *
14 * The IgH EtherCAT master userspace program in the ROS2 environment is distributed in the hope that
15 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the IgH EtherCAT master userspace program in the ROS environment. If not, see
21 * <http://www.gnu.org/licenses/>.
22 *
23 * ---
24 *
25 * The license mentioned above concerns the source code only. Using the
26 * EtherCAT technology and brand is only permitted in compliance with the
27 * industrial property and similar rights of Beckhoff Automation GmbH.
28 *
29 * Contact information: veysi.adin@kist.re.kr
30 *****************************************************************************/
31/*****************************************************************************
32 * \file gui_node.hpp
33 * \brief GUI node implementation to show slave status and controller commands in ROS2.
34 * Additionally it publishes information regarding buttons on mainscreen.
35 * GUI node is a ROS2 node which subscribes EthercatLifecycle Node topics and
36 * controller topics and shows those values via GUI and publishes control ui
37 * button values.
38 *******************************************************************************/
39
40#pragma once
41//ROS2
42#include "rclcpp/rclcpp.hpp"
43
44// Message file headers, -custom and built-in-
45#include "sensor_msgs/msg/joy.hpp"
46#include "ecat_msgs/msg/data_received.hpp"
47#include "ecat_msgs/msg/data_sent.hpp"
48#include "ecat_msgs/msg/gui_button_data.hpp"
49#include "std_msgs/msg/u_int16.hpp"
50#include "ecat_globals.hpp"
51//CPP
52#include <vector>
53#include <chrono>
54#include <memory>
55#include <functional>
56#include <string>
57#include <cstdint>
58#include <ctime>
59#include <ratio>
60#include <fstream>
61#include <string>
62#include "timing.hpp"
63#include "gui_globals.hpp"
64
65using namespace std::chrono_literals;
66
67namespace GUI {
68
74 class GuiNode : public rclcpp::Node
75 {
76
77 private:
82 void timer_callback();
90 void HandleControllerCallbacks(const sensor_msgs::msg::Joy::SharedPtr msg);
98 void HandleMasterCommandCallbacks(const ecat_msgs::msg::DataSent::SharedPtr msg);
106 void HandleSlaveFeedbackCallbacks(const ecat_msgs::msg::DataReceived::SharedPtr msg);
111
112 void HandleSafetyNodeCallback(const std_msgs::msg::UInt16::SharedPtr msg);
113 private:
116 rclcpp::Subscription<ecat_msgs::msg::DataReceived>::SharedPtr slave_feedback_;
117
119 rclcpp::Subscription<ecat_msgs::msg::DataSent>::SharedPtr master_commands_;
120
121 rclcpp::Subscription<sensor_msgs::msg::Joy>::SharedPtr controller_commands_;
122
123 rclcpp::Subscription<std_msgs::msg::UInt16>::SharedPtr safety_info_subscriber_;
124
126 rclcpp::TimerBase::SharedPtr timer_;
127
129 rclcpp::Publisher<ecat_msgs::msg::GuiButtonData>::SharedPtr gui_publisher_;
130
131 public:
132 GuiNode();
133 virtual ~GuiNode();
134 public:
136 ecat_msgs::msg::DataReceived slave_feedback_data_;
137 ecat_msgs::msg::DataSent master_command_data_;
139 ecat_msgs::msg::GuiButtonData ui_control_buttons_;
140 std_msgs::msg::UInt16 safety_info_;
144 };// class GuiNode
145
146 } // namespace GUI
This node will be responsible from all GUI interaction and visualization of feedback information acqu...
Definition: gui_node.hpp:75
rclcpp::Subscription< sensor_msgs::msg::Joy >::SharedPtr controller_commands_
Definition: gui_node.hpp:121
rclcpp::Subscription< ecat_msgs::msg::DataReceived >::SharedPtr slave_feedback_
Definition: gui_node.hpp:116
std_msgs::msg::UInt16 safety_info_
Definition: gui_node.hpp:140
rclcpp::Publisher< ecat_msgs::msg::GuiButtonData >::SharedPtr gui_publisher_
Gui publisher, which contains clicked button information.
Definition: gui_node.hpp:129
ecat_msgs::msg::GuiButtonData ui_control_buttons_
GUI button value to publish emergency button state.
Definition: gui_node.hpp:139
rclcpp::Subscription< std_msgs::msg::UInt16 >::SharedPtr safety_info_subscriber_
Definition: gui_node.hpp:123
void HandleMasterCommandCallbacks(const ecat_msgs::msg::DataSent::SharedPtr msg)
Function will be used for subscribtion callbacks from EthercatLifecycle node for Master_Commands topi...
Definition: gui_node.cpp:56
uint8_t current_lifecycle_state
Definition: gui_node.hpp:143
void HandleSlaveFeedbackCallbacks(const ecat_msgs::msg::DataReceived::SharedPtr msg)
Function will be used for subscribtion callbacks from EthercatLifecycle node for Master_Commands topi...
Definition: gui_node.cpp:67
rclcpp::TimerBase::SharedPtr timer_
Timer for timer callbacks, publishing will be done in certain interval.
Definition: gui_node.hpp:126
void HandleControllerCallbacks(const sensor_msgs::msg::Joy::SharedPtr msg)
Function will be used for subscribtion callbacks from controller node for Controller topic.
Definition: gui_node.cpp:47
GuiNode()
Definition: gui_node.cpp:7
virtual ~GuiNode()
Definition: gui_node.cpp:35
Timing time_info_
For time measurements.
Definition: gui_node.hpp:142
void timer_callback()
Publishes gui button value in specified interval.
Definition: gui_node.cpp:40
void ResetContolButtonValues()
Resets control button values coming from control UI.
Definition: gui_node.cpp:88
rclcpp::Subscription< ecat_msgs::msg::DataSent >::SharedPtr master_commands_
Subscribed to commands that's being sent by ecat_master.
Definition: gui_node.hpp:119
ecat_msgs::msg::DataReceived slave_feedback_data_
Received data structure to store all subscribed data.
Definition: gui_node.hpp:136
void HandleSafetyNodeCallback(const std_msgs::msg::UInt16::SharedPtr msg)
ecat_msgs::msg::DataSent master_command_data_
Definition: gui_node.hpp:137
Definition: gui_node.hpp:67
Definition: timing_node.hpp:41