|
1 | | -#ifndef INCLUDE_HAL_HPP_ |
2 | | -#define INCLUDE_HAL_HPP_ |
3 | | - |
4 | | -#include <array> |
5 | | -#include <memory> |
6 | | -#include <thread> |
7 | | - |
8 | | -// Forward declarations to keep ROS 2 headers out of user-facing code. |
9 | | -class HALNode; |
10 | | -namespace rclcpp::executors { class MultiThreadedExecutor; } |
11 | | - |
12 | | -class HAL |
13 | | -{ |
14 | | -public: |
15 | | - // Prevent instantiation. HAL acts as a global static utility. |
16 | | - HAL() = delete; |
17 | | - |
18 | | - // Absolute joint movement. joints[6] in degrees, speed in [0,1], wait_time in seconds. |
19 | | - static void MoveAbsJ(const std::array<double, 6>& joints, double speed, double wait_time); |
20 | | - |
21 | | - // Relative single-joint movement. joint_number in [1,6], relative_angle in degrees. |
22 | | - static void MoveSingleJ(int joint_number, double relative_angle, double speed, double wait_time); |
23 | | - |
24 | | - // Absolute linear (Cartesian) move. xyz in metres, ypr in degrees. |
25 | | - static void MoveLinear(const std::array<double, 3>& xyz, const std::array<double, 3>& ypr, double speed, double wait_time); |
26 | | - |
27 | | - // Absolute point-to-point (Cartesian) move. xyz in metres, ypr in degrees. |
28 | | - static void MoveJoint(const std::array<double, 3>& xyz, const std::array<double, 3>& ypr, double speed, double wait_time); |
29 | | - |
30 | | - // Relative linear Cartesian increment. xyz in metres. |
31 | | - static void MoveRelLinear(const std::array<double, 3>& xyz, double speed, double wait_time); |
32 | | - |
33 | | - // Relative TCP reorientation. ypr in degrees. |
34 | | - static void MoveRelReor(const std::array<double, 3>& ypr, double speed, double wait_time); |
35 | | - |
36 | | - // Gripper control. relative_closure in [0,100] (0 = fully open, 100 = fully closed). |
37 | | - static void GripperSet(double relative_closure, double wait_time); |
38 | | - |
39 | | -private: |
40 | | - static void init(); |
41 | | - friend class SystemBootstrapper; |
42 | | - |
43 | | - // Hidden internal state. Not accessible to the user. |
44 | | - static std::shared_ptr<HALNode> hal_node_; |
45 | | - static std::shared_ptr<rclcpp::executors::MultiThreadedExecutor> executor_; |
46 | | - static std::thread spin_thread_; |
47 | | -}; |
48 | | - |
49 | | -#endif |
| 1 | +#ifndef INCLUDE_HAL_HPP_ |
| 2 | +#define INCLUDE_HAL_HPP_ |
| 3 | + |
| 4 | +#include <array> |
| 5 | +#include <memory> |
| 6 | +#include <thread> |
| 7 | + |
| 8 | +// Forward declarations to keep ROS 2 headers out of user-facing code. |
| 9 | +class HALNode; |
| 10 | +namespace rclcpp::executors { class MultiThreadedExecutor; } |
| 11 | + |
| 12 | +class HAL |
| 13 | +{ |
| 14 | +public: |
| 15 | + // Prevent instantiation. HAL acts as a global static utility. |
| 16 | + HAL() = delete; |
| 17 | + |
| 18 | + // Absolute joint movement. joints[6] in degrees, speed in [0,1], wait_time in seconds. |
| 19 | + static void MoveAbsJ(const std::array<double, 6>& joints, double speed, double wait_time); |
| 20 | + |
| 21 | + // Relative single-joint movement. joint_number in [1,6], relative_angle in degrees. |
| 22 | + static void MoveSingleJ(int joint_number, double relative_angle, double speed, double wait_time); |
| 23 | + |
| 24 | + // Absolute linear (Cartesian) move. xyz in metres, ypr in degrees. |
| 25 | + static void MoveLinear(const std::array<double, 3>& xyz, const std::array<double, 3>& ypr, double speed, double wait_time); |
| 26 | + |
| 27 | + // Absolute point-to-point (Cartesian) move. xyz in metres, ypr in degrees. |
| 28 | + static void MoveJoint(const std::array<double, 3>& xyz, const std::array<double, 3>& ypr, double speed, double wait_time); |
| 29 | + |
| 30 | + // Relative linear Cartesian increment. xyz in metres. |
| 31 | + static void MoveRelLinear(const std::array<double, 3>& xyz, double speed, double wait_time); |
| 32 | + |
| 33 | + // Relative TCP reorientation. ypr in degrees. |
| 34 | + static void MoveRelReor(const std::array<double, 3>& ypr, double speed, double wait_time); |
| 35 | + |
| 36 | + // Suction gripper control. on = true grips a graspable object in contact |
| 37 | + // with the cup, on = false releases the held object. wait_time in seconds. |
| 38 | + static void SuctionSet(bool on, double wait_time); |
| 39 | + |
| 40 | +private: |
| 41 | + static void init(); |
| 42 | + friend class SystemBootstrapper; |
| 43 | + |
| 44 | + // Hidden internal state. Not accessible to the user. |
| 45 | + static std::shared_ptr<HALNode> hal_node_; |
| 46 | + static std::shared_ptr<rclcpp::executors::MultiThreadedExecutor> executor_; |
| 47 | + static std::thread spin_thread_; |
| 48 | +}; |
| 49 | + |
| 50 | +#endif |
0 commit comments