EtherCAT Control Framework v0.9
Implementation of EtherCAT protocol using IgH EtherCAT library for robot controller.
hapticNode.hpp
Go to the documentation of this file.
1// ---------------------------------------------------------------
2// Ckim - Haptic Device Node (client) for ROS2
3// Connects to haptic device PC (master) by TCP/IP
4// reads incoming data and publishes HapticCmd
5// Based on ROS2 joystick node code at
6// https://github.com/ros-drivers/joystick_drivers/tree/ros2/joy
7// ---------------------------------------------------------------
8
9#ifndef HAPTICNODE
10#define HAPTICNODE
11
12// CKim - SDL = Simple DirectMedia Layer is cross-platform development library designed
13// to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via
14// OpenGL and Direct3D. Used for joystickinput processing here
15#include <SDL2/SDL.h>
16
17// CKim - C++ headers
18#include <future>
19#include <memory>
20#include <string>
21#include <thread>
22
23#include <rclcpp/rclcpp.hpp>
24#include "ecat_msgs/msg/haptic_cmd.hpp" // CKim - Header for custom message
25
26class HapticNode final : public rclcpp::Node // keyword 'final' prevents further inheritance
27{
28public:
29
30 // CKim - Keyword 'explicit' restricts implicit conversion
31 explicit HapticNode(char * argv[]);
32
33 // CKim - Restrict copy constructors and assignment operator =
34 // keyword 'delete' tells these functions will not be implemented.
35 HapticNode(HapticNode && c) = delete;
37 HapticNode(const HapticNode & c) = delete;
38 HapticNode & operator=(const HapticNode & c) = delete;
39
40 // CKim - Keyword 'override' tell compiler that this inherited function must be implemented
41 ~HapticNode() override;
42
43private:
44 void commThread();
45
46 // CKim - C++ standard thread,
47 // std::future/shared_future and promise provides a mechanism to
48 // control therad....
49 std::thread comm_thread_;
50 std::shared_future<void> future_;
51 std::promise<void> exit_signal_;
52
53 std::string m_IP;
54 std::string m_Port;
55
56 // CKim - Publisher
57 rclcpp::Publisher<ecat_msgs::msg::HapticCmd>::SharedPtr haptic_publisher_;
58
59 // CKim - Published message
60 ecat_msgs::msg::HapticCmd hapticMsg;
61 // rclcpp::Publisher<sensor_msgs::msg::Joy>::SharedPtr pub_;
62 // rclcpp::Subscription<sensor_msgs::msg::JoyFeedback>::SharedPtr feedback_sub_;
63 // sensor_msgs::msg::Joy joy_msg_;
64};
65
66
67#endif // JOY__JOY_HPP_
Definition: hapticNode.hpp:27
HapticNode & operator=(const HapticNode &c)=delete
std::string m_Port
Definition: hapticNode.hpp:54
~HapticNode() override
Definition: hapticNode.cpp:160
void commThread()
Definition: hapticNode.cpp:59
std::promise< void > exit_signal_
Definition: hapticNode.hpp:51
std::thread comm_thread_
Definition: hapticNode.hpp:49
HapticNode(char *argv[])
Definition: hapticNode.cpp:35
HapticNode(const HapticNode &c)=delete
std::string m_IP
Definition: hapticNode.hpp:53
ecat_msgs::msg::HapticCmd hapticMsg
Definition: hapticNode.hpp:60
rclcpp::Publisher< ecat_msgs::msg::HapticCmd >::SharedPtr haptic_publisher_
Definition: hapticNode.hpp:57
HapticNode & operator=(HapticNode &&c)=delete
std::shared_future< void > future_
Definition: hapticNode.hpp:50
HapticNode(HapticNode &&c)=delete