diff --git a/src/rc_msgs/.gitignore b/src/rc_msgs/.gitignore new file mode 100644 index 0000000..35d74bb --- /dev/null +++ b/src/rc_msgs/.gitignore @@ -0,0 +1,51 @@ +devel/ +logs/ +build/ +bin/ +lib/ +msg_gen/ +srv_gen/ +msg/*Action.msg +msg/*ActionFeedback.msg +msg/*ActionGoal.msg +msg/*ActionResult.msg +msg/*Feedback.msg +msg/*Goal.msg +msg/*Result.msg +msg/_*.py +build_isolated/ +devel_isolated/ + +# Generated by dynamic reconfigure +*.cfgc +/cfg/cpp/ +/cfg/*.py + +# Ignore generated docs +*.dox +*.wikidoc + +# eclipse stuff +.project +.cproject + +# qcreator stuff +CMakeLists.txt.user + +srv/_*.py +*.pcd +*.pyc +qtcreator-* +*.user + +/planning/cfg +/planning/docs +/planning/src + +*~ + +# Emacs +.#* + +# Catkin custom files +CATKIN_IGNORE diff --git a/src/rc_msgs/CMakeLists.txt b/src/rc_msgs/CMakeLists.txt new file mode 100644 index 0000000..e2b1db6 --- /dev/null +++ b/src/rc_msgs/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(rc_msgs) + +find_package(rosidl_default_generators REQUIRED) +rosidl_generate_interfaces(${PROJECT_NAME} + "msg/Ps2Data.msg" + "msg/DataControl.msg" + "msg/DataMotor.msg" +) + +ament_package() + diff --git a/src/rc_msgs/LICENSE b/src/rc_msgs/LICENSE new file mode 100644 index 0000000..cb386d0 --- /dev/null +++ b/src/rc_msgs/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 zucheng Lv + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/rc_msgs/README.md b/src/rc_msgs/README.md new file mode 100644 index 0000000..1394a44 --- /dev/null +++ b/src/rc_msgs/README.md @@ -0,0 +1,6 @@ +# rc_msg +Some ROS 2 custom messages for Robotaster + +Usage +Modify or add files in the /msg directory as needed +colcon build \ No newline at end of file diff --git a/src/rc_msgs/msg/DataControl.msg b/src/rc_msgs/msg/DataControl.msg new file mode 100644 index 0000000..b27ecb6 --- /dev/null +++ b/src/rc_msgs/msg/DataControl.msg @@ -0,0 +1,5 @@ +int16 tau +int16 vw +int32 pos +uint16 kp +uint16 kd \ No newline at end of file diff --git a/src/rc_msgs/msg/DataMotor.msg b/src/rc_msgs/msg/DataMotor.msg new file mode 100644 index 0000000..94c1c54 --- /dev/null +++ b/src/rc_msgs/msg/DataMotor.msg @@ -0,0 +1,3 @@ +int16 tau +int16 vw +int32 pos \ No newline at end of file diff --git a/src/rc_msgs/msg/Ps2Data.msg b/src/rc_msgs/msg/Ps2Data.msg new file mode 100644 index 0000000..2b52c1c --- /dev/null +++ b/src/rc_msgs/msg/Ps2Data.msg @@ -0,0 +1,20 @@ +# control input message +float32 lx +float32 ly +float32 rx +float32 ry + +float32 up_down +float32 left_right + +bool l1 +bool l2 +bool r1 +bool r2 + +# 四种模式 +uint8 mode # 0:手柄控制 1:键盘控制 2:自瞄 3:手动瞄准 + +bool select +bool start + diff --git a/src/rc_msgs/package.xml b/src/rc_msgs/package.xml new file mode 100644 index 0000000..91ec4a6 --- /dev/null +++ b/src/rc_msgs/package.xml @@ -0,0 +1,16 @@ + + + rc_msgs + 0.0.1 + Describe custom messages + biao + MIT + + rosidl_default_generators + rosidl_default_runtime + rosidl_interface_packages + + + ament_cmake + + \ No newline at end of file diff --git a/src/unitree_motor_serial_driver/include/unitree_motor_serial_driver/unitree_motor_serial_driver.hpp b/src/unitree_motor_serial_driver/include/unitree_motor_serial_driver/unitree_motor_serial_driver.hpp index 717ee65..0288112 100644 --- a/src/unitree_motor_serial_driver/include/unitree_motor_serial_driver/unitree_motor_serial_driver.hpp +++ b/src/unitree_motor_serial_driver/include/unitree_motor_serial_driver/unitree_motor_serial_driver.hpp @@ -17,6 +17,13 @@ struct Motor_t MotorData data; }; +// struct Leg_Motor_t +// { +// Motor_t foot; +// Motor_t small; +// Motor_t big; +// }; + class MotorControlNode : public rclcpp::Node { public: diff --git a/src/unitree_motor_serial_driver/src/unitree_motor_serial_driver.cpp b/src/unitree_motor_serial_driver/src/unitree_motor_serial_driver.cpp index bd436d5..fe42d64 100644 --- a/src/unitree_motor_serial_driver/src/unitree_motor_serial_driver.cpp +++ b/src/unitree_motor_serial_driver/src/unitree_motor_serial_driver.cpp @@ -19,8 +19,8 @@ void MotorControlNode::control_motor() data.motorType = MotorType::GO_M8010_6; cmd.mode = queryMotorMode(MotorType::GO_M8010_6, MotorMode::FOC); cmd.id = 0; - cmd.q = 0.0; - cmd.dq = 0.0; + cmd.q = 0.0*queryGearRatio(MotorType::GO_M8010_6);; + cmd.dq = 0.0*queryGearRatio(MotorType::GO_M8010_6);; cmd.kp = 0.0; cmd.kd = 0.0; cmd.tau = 0.0;