From 1f9fdc40594d6bf73b30f393cbd19f2773db1434 Mon Sep 17 00:00:00 2001 From: hanjun Date: Mon, 13 Oct 2025 16:00:54 +0800 Subject: [PATCH] update aimrt and fix joint sensor reader --- cmake/GetAimRT.cmake | 2 +- .../mujoco_sim_module/common/xmodel_reader.cc | 22 +++++++-- .../subscriber/joint_actuator_subscriber.cc | 4 +- src/protocols/CMakeLists.txt | 1 - src/protocols/actuator/CMakeLists.txt | 40 ---------------- src/protocols/actuator/joint_command.proto | 47 ------------------- 6 files changed, 20 insertions(+), 96 deletions(-) delete mode 100644 src/protocols/actuator/CMakeLists.txt delete mode 100644 src/protocols/actuator/joint_command.proto diff --git a/cmake/GetAimRT.cmake b/cmake/GetAimRT.cmake index e0070bd..28adaee 100644 --- a/cmake/GetAimRT.cmake +++ b/cmake/GetAimRT.cmake @@ -6,7 +6,7 @@ include(FetchContent) message(STATUS "get aimrt ...") set(aimrt_DOWNLOAD_URL - "https://github.com/AimRT/AimRT/archive/refs/tags/v0.10.0.tar.gz" + "https://github.com/AimRT/AimRT/archive/refs/tags/v1.2.0.tar.gz" CACHE STRING "") if(aimrt_LOCAL_SOURCE) diff --git a/src/module/mujoco_sim_module/common/xmodel_reader.cc b/src/module/mujoco_sim_module/common/xmodel_reader.cc index 5dab297..fc81d3a 100644 --- a/src/module/mujoco_sim_module/common/xmodel_reader.cc +++ b/src/module/mujoco_sim_module/common/xmodel_reader.cc @@ -20,16 +20,28 @@ std::optional GetJointSensorIdByJointName(const mjModel* m, std::string return std::nullopt; } -std::optional GetJointvelIdByJointName(const mjModel* m, std::string_view joint_name) { - return GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTVEL); +std::optional GetJointposIdByJointName(const mjModel* m, std::string_view joint_name) { + auto sensor_id = GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTPOS); + if (!sensor_id.has_value()) { + return std::nullopt; + } + return m->sensor_adr[sensor_id.value()]; } -std::optional GetJointposIdByJointName(const mjModel* m, std::string_view joint_name) { - return GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTPOS); +std::optional GetJointvelIdByJointName(const mjModel* m, std::string_view joint_name) { + auto sensor_id = GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTVEL); + if (!sensor_id.has_value()) { + return std::nullopt; + } + return m->sensor_adr[sensor_id.value()]; } std::optional GetJointactfrcIdByJointName(const mjModel* m, std::string_view joint_name) { - return GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTACTFRC); + auto sensor_id = GetJointSensorIdByJointName(m, joint_name, mjSENS_JOINTACTFRC); + if (!sensor_id.has_value()) { + return std::nullopt; + } + return m->sensor_adr[sensor_id.value()]; } std::optional GetJointSensorNameByJointName(const mjModel* m, std::string_view joint_name, mjtSensor sensor_type) { diff --git a/src/module/mujoco_sim_module/subscriber/joint_actuator_subscriber.cc b/src/module/mujoco_sim_module/subscriber/joint_actuator_subscriber.cc index 1bb96f3..a3f8ca7 100644 --- a/src/module/mujoco_sim_module/subscriber/joint_actuator_subscriber.cc +++ b/src/module/mujoco_sim_module/subscriber/joint_actuator_subscriber.cc @@ -113,8 +113,8 @@ void JointActuatorSubscriber::EventHandle(const std::shared_ptr