From 2bdb5671ee80c6cf0626f5154d8a70ee3cddd2c1 Mon Sep 17 00:00:00 2001 From: Rooholla-KhorramBakht Date: Fri, 9 Feb 2024 11:14:54 +0800 Subject: [PATCH] joystick header added --- .../src/go2py_node/include/joystick.h | 44 +++++++++++++++++++ deploy/robot_ws/src/go2py_node/src/bridge.cpp | 2 + deploy/scripts/hw_start.sh | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 deploy/robot_ws/src/go2py_node/include/joystick.h diff --git a/deploy/robot_ws/src/go2py_node/include/joystick.h b/deploy/robot_ws/src/go2py_node/include/joystick.h new file mode 100644 index 0000000..8be7315 --- /dev/null +++ b/deploy/robot_ws/src/go2py_node/include/joystick.h @@ -0,0 +1,44 @@ +/***************************************************************** +Copyright (c) 2020, Unitree Robotics.Co.Ltd. All rights reserved. +*****************************************************************/ +#ifndef _UNITREE_LEGGED_JOYSTICK_H_ +#define _UNITREE_LEGGED_JOYSTICK_H_ + +#include +// 16b +typedef union { + struct { + uint8_t R1 : 1; + uint8_t L1 : 1; + uint8_t start : 1; + uint8_t select : 1; + uint8_t R2 : 1; + uint8_t L2 : 1; + uint8_t F1 : 1; + uint8_t F2 : 1; + uint8_t A : 1; + uint8_t B : 1; + uint8_t X : 1; + uint8_t Y : 1; + uint8_t up : 1; + uint8_t right : 1; + uint8_t down : 1; + uint8_t left : 1; + } components; + uint16_t value; +} xKeySwitchUnion; + +// 40 Byte (now used 24B) +typedef struct { + uint8_t head[2]; + xKeySwitchUnion btn; + float lx; + float rx; + float ry; + float L2; + float ly; + + uint8_t idle[16]; +} xRockerBtnDataStruct; + +#endif // _UNITREE_LEGGED_JOYSTICK_H_ \ No newline at end of file diff --git a/deploy/robot_ws/src/go2py_node/src/bridge.cpp b/deploy/robot_ws/src/go2py_node/src/bridge.cpp index 532c5b9..4860cba 100644 --- a/deploy/robot_ws/src/go2py_node/src/bridge.cpp +++ b/deploy/robot_ws/src/go2py_node/src/bridge.cpp @@ -22,6 +22,7 @@ #include "unitree_go/msg/sport_mode_state.hpp" #include "unitree_api/msg/request.hpp" #include "common/ros2_sport_client.h" +#include "joystick.h" class Custom: public rclcpp::Node { @@ -79,6 +80,7 @@ class Custom: public rclcpp::Node rclcpp::Publisher::SharedPtr lowcmd_puber; unitree_go::msg::LowCmd lowcmd_msg; uint64_t last_lowcmd_stamp = 0; + xRockerBtnDataStruct _keyData; void init_lowcmd() { diff --git a/deploy/scripts/hw_start.sh b/deploy/scripts/hw_start.sh index 86737b3..c5804bb 100644 --- a/deploy/scripts/hw_start.sh +++ b/deploy/scripts/hw_start.sh @@ -1 +1 @@ -source /ros2_ws/install/setup.bash && ros2 launch /root/launch/hw.launch.py \ No newline at end of file +source /dock_ws/install/setup.bash && ros2 launch /root/launch/hw.launch.py \ No newline at end of file