From 2a5ef98649d961ed70a483fb0f831b8b1c336be6 Mon Sep 17 00:00:00 2001 From: linbo <1034003879@qq.com> Date: Thu, 12 Nov 2026 09:52:17 +0800 Subject: [PATCH] fix(arm): track power command results and sync 206 device templates Initialize arm power state to false and update it only after successful arm-level enable or disable commands. Preserve Lingkong drive feedback diagnostics and add focused MuJoCo regression tests. Sync deployment templates from device 206, remove 209-specific neck/left-hand entries, and keep all 40 device entries disabled in version control. Preserve deployed runtime switches separately. --- cmvr-es/config/devices/arm/aubo_arm.pb.txt | 2 +- .../devices/arm/lingkong_mixed_arm.pb.txt | 31 +++++++++ cmvr-es/config/devices/arm/neck_arm.pb.txt | 28 --------- cmvr-es/config/devices/dexhand/dexhand.pb.txt | 13 +--- .../motor/lingkong_mixed_motors.pb.txt | 62 ++++++++++++++++++ .../config/devices/motor/neck_motors.pb.txt | 49 --------------- cmvr-es/config/manager/device_manager.pb.txt | 63 ++++++------------- .../quic_edge_task/quic_edge_task.pb.txt | 12 ---- .../motor_robot_arm/include/motor_robot_arm.h | 2 + .../motor_robot_arm/src/motor_robot_arm.cpp | 6 +- .../src/motor_robot_arm_gen2_mujoco_test.cpp | 26 ++++++++ 11 files changed, 147 insertions(+), 147 deletions(-) create mode 100644 cmvr-es/config/devices/arm/lingkong_mixed_arm.pb.txt delete mode 100644 cmvr-es/config/devices/arm/neck_arm.pb.txt create mode 100644 cmvr-es/config/devices/motor/lingkong_mixed_motors.pb.txt delete mode 100644 cmvr-es/config/devices/motor/neck_motors.pb.txt diff --git a/cmvr-es/config/devices/arm/aubo_arm.pb.txt b/cmvr-es/config/devices/arm/aubo_arm.pb.txt index e290fe1b..1a45cefb 100644 --- a/cmvr-es/config/devices/arm/aubo_arm.pb.txt +++ b/cmvr-es/config/devices/arm/aubo_arm.pb.txt @@ -17,7 +17,7 @@ arm { tool_frame: "tool0" username: "aubo" password: "123456" - auto_enable: false + auto_enable: true } } } diff --git a/cmvr-es/config/devices/arm/lingkong_mixed_arm.pb.txt b/cmvr-es/config/devices/arm/lingkong_mixed_arm.pb.txt new file mode 100644 index 00000000..9246df32 --- /dev/null +++ b/cmvr-es/config/devices/arm/lingkong_mixed_arm.pb.txt @@ -0,0 +1,31 @@ +# Three-axis joint-only group. MoveJ positions follow joint_names order (rad). +# CAN commands are sent per axis; this is not hardware-triggered synchronization. +arm { + robot_arms { + id: "lingkong_mixed_arm" + motor { + motor_system_id: "lingkong_mixed_motors" + motor_group_ids: "lingkong_mixed_v236" + motor_group_ids: "lingkong_mixed_v238" + dof: 3 + joint_names: "LINGKONG_MIXED_AXIS_1" + joint_names: "LINGKONG_MIXED_AXIS_2" + joint_names: "LINGKONG_MIXED_AXIS_3" + upd_freq: 50 + } + motion { + joint_trajectory_smoother { + sample_period_s: 0.02 + quintic_bspline { + control_point_spacing_rad: 0.1 + } + } + move_j { + settle_timeout_s: 2.0 + settle_position_tolerance_rad: 0.002 + settle_velocity_tolerance_rad_s: 0.02 + settle_stable_sample_count: 3 + } + } + } +} diff --git a/cmvr-es/config/devices/arm/neck_arm.pb.txt b/cmvr-es/config/devices/arm/neck_arm.pb.txt deleted file mode 100644 index b5b8fd15..00000000 --- a/cmvr-es/config/devices/arm/neck_arm.pb.txt +++ /dev/null @@ -1,28 +0,0 @@ -# Independent joint-only neck; joint order follows motor IDs 1, 2, 3. -arm { - robot_arms { - id: "neck_arm" - motor { - motor_system_id: "neck_can_motors" - motor_group_ids: "neck_v236" - motor_group_ids: "neck_v238" - dof: 3 - joint_names: "neck_joint_1" - joint_names: "neck_joint_2" - joint_names: "neck_joint_3" - upd_freq: 50 - } - motion { - joint_trajectory_smoother { - sample_period_s: 0.02 - quintic_bspline { control_point_spacing_rad: 0.1 } - } - move_j { - settle_timeout_s: 2.0 - settle_position_tolerance_rad: 0.002 - settle_velocity_tolerance_rad_s: 0.02 - settle_stable_sample_count: 3 - } - } - } -} diff --git a/cmvr-es/config/devices/dexhand/dexhand.pb.txt b/cmvr-es/config/devices/dexhand/dexhand.pb.txt index f75cdc56..ed9d980c 100644 --- a/cmvr-es/config/devices/dexhand/dexhand.pb.txt +++ b/cmvr-es/config/devices/dexhand/dexhand.pb.txt @@ -20,7 +20,7 @@ dexhand { model: "ROH-LiteS001" has_tactile_feedback: false oymotion_ap001 { - can_interface: "b5d2can0" + can_interface: "can0" hand_id: 2 master_id: 1 command_timeout_ms: 255 @@ -81,15 +81,4 @@ dexhand { has_tactile_feedback: true zero_sim_touch {} } - dexhands { - id: "left_hand_lites001" - model: "ROH-LiteS001" - has_tactile_feedback: false - oymotion_ap001 { - can_interface: "b5d2can1" - hand_id: 2 - master_id: 1 - command_timeout_ms: 255 - } - } } diff --git a/cmvr-es/config/devices/motor/lingkong_mixed_motors.pb.txt b/cmvr-es/config/devices/motor/lingkong_mixed_motors.pb.txt new file mode 100644 index 00000000..55c4522c --- /dev/null +++ b/cmvr-es/config/devices/motor/lingkong_mixed_motors.pb.txt @@ -0,0 +1,62 @@ +# Alternative deployment: do not enable together with the original can3 IDs 1/2/3. +# Both groups are loaded by the MotorConfig.id below, with unique motor IDs. +motor { + id: "lingkong_mixed_motors" + motor_groups { + id: "lingkong_mixed_v236" + bus_type: MOTOR_BUS_CAN + vendor: MOTOR_VENDOR_LINGKONG + protocol: MOTOR_PROTOCOL_LINGKONG_CAN + can { channel_id: 3 } + motors { + motors { + id: 1 + joint_name: "LINGKONG_MIXED_AXIS_1" + gear_ratio: 10 + limit_q_lb: -3.14 + limit_q_ub: 3.14 + limit_qd: 10 + lingkong { + response_timeout_ms: 100 + reached_position_tolerance_rad: 0.001 + # Iq conversion intentionally unspecified until confirmed for this motor. + } + } + } + } + motor_groups { + id: "lingkong_mixed_v238" + bus_type: MOTOR_BUS_CAN + vendor: MOTOR_VENDOR_LINGKONG + protocol: MOTOR_PROTOCOL_LINGKONG_CAN_V2_38 + can { channel_id: 3 } + motors { + motors { + id: 2 + joint_name: "LINGKONG_MIXED_AXIS_2" + gear_ratio: 10 + limit_q_lb: -3.14 + limit_q_ub: 3.14 + limit_qd: 10 + lingkong { + response_timeout_ms: 100 + reached_position_tolerance_rad: 0.001 + # Iq conversion intentionally unspecified until confirmed for this motor. + } + } + motors { + id: 3 + joint_name: "LINGKONG_MIXED_AXIS_3" + gear_ratio: 10 + limit_q_lb: -3.14 + limit_q_ub: 3.14 + limit_qd: 10 + lingkong { + response_timeout_ms: 100 + reached_position_tolerance_rad: 0.001 + # Iq conversion intentionally unspecified until confirmed for this motor. + } + } + } + } +} diff --git a/cmvr-es/config/devices/motor/neck_motors.pb.txt b/cmvr-es/config/devices/motor/neck_motors.pb.txt deleted file mode 100644 index a50fc3a7..00000000 --- a/cmvr-es/config/devices/motor/neck_motors.pb.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Neck: CAN2, ID1 V2.36; ID2/3 V2.38. Output shaft units: rad, rad/s. -motor { - id: "neck_can_motors" - motor_groups { - id: "neck_v236" - bus_type: MOTOR_BUS_CAN - vendor: MOTOR_VENDOR_LINGKONG - protocol: MOTOR_PROTOCOL_LINGKONG_CAN - can { channel_id: 2 } - motors { - motors { - id: 1 - joint_name: "neck_joint_1" - gear_ratio: 10 - limit_q_lb: -3.14 - limit_q_ub: 3.14 - limit_qd: 10 - lingkong { response_timeout_ms: 100 reached_position_tolerance_rad: 0.001 } - } - } - } - motor_groups { - id: "neck_v238" - bus_type: MOTOR_BUS_CAN - vendor: MOTOR_VENDOR_LINGKONG - protocol: MOTOR_PROTOCOL_LINGKONG_CAN_V2_38 - can { channel_id: 2 } - motors { - motors { - id: 2 - joint_name: "neck_joint_2" - gear_ratio: 10 - limit_q_lb: -3.14 - limit_q_ub: 3.14 - limit_qd: 10 - lingkong { response_timeout_ms: 100 reached_position_tolerance_rad: 0.001 } - } - motors { - id: 3 - joint_name: "neck_joint_3" - gear_ratio: 10 - limit_q_lb: -3.14 - limit_q_ub: 3.14 - limit_qd: 10 - lingkong { response_timeout_ms: 100 reached_position_tolerance_rad: 0.001 } - } - } - } -} diff --git a/cmvr-es/config/manager/device_manager.pb.txt b/cmvr-es/config/manager/device_manager.pb.txt index 7d02c685..b838ed69 100644 --- a/cmvr-es/config/manager/device_manager.pb.txt +++ b/cmvr-es/config/manager/device_manager.pb.txt @@ -66,6 +66,13 @@ device_manager { enable: false } + devices { + id: "right_hand_lites001" + type: DEVICE_TYPE_DEXHAND + config_file: "devices/dexhand/dexhand.pb.txt" + enable: false + } + devices { id: "hand2" type: DEVICE_TYPE_DEXHAND @@ -207,23 +214,23 @@ device_manager { } devices { - id: "dual_arm_ethercat_motors" + id: "tchl_dual_arm_motors" type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/dual_arm_ethercat_motors.pb.txt" + config_file: "devices/motor/tchl_dual_arm_motors.pb.txt" enable: false } devices { - id: "right_ethercat_arm" + id: "right_tchl_arm" type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/ethercat_single_arm.pb.txt" + config_file: "devices/arm/tchl_dual_arm.pb.txt" enable: false } devices { - id: "left_ethercat_arm" + id: "left_tchl_arm" type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/ethercat_dual_arm.pb.txt" + config_file: "devices/arm/tchl_dual_arm.pb.txt" enable: false } @@ -258,47 +265,17 @@ device_manager { enable: false } - + # Alternative hardware deployment; enable only on the matching device. devices { - id: "tchl_dual_arm_motors" + id: "lingkong_mixed_motors" type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/tchl_dual_arm_motors.pb.txt" - enable: true + config_file: "devices/motor/lingkong_mixed_motors.pb.txt" + enable: false } devices { - id: "right_tchl_arm" + id: "lingkong_mixed_arm" type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/tchl_dual_arm.pb.txt" - enable: true - } - devices { - id: "left_tchl_arm" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/tchl_dual_arm.pb.txt" - enable: true - } - devices { - id: "right_hand_lites001" - type: DEVICE_TYPE_DEXHAND - config_file: "devices/dexhand/dexhand.pb.txt" - enable: true - } - devices { - id: "left_hand_lites001" - type: DEVICE_TYPE_DEXHAND - config_file: "devices/dexhand/dexhand.pb.txt" - enable: true - } - devices { - id: "neck_can_motors" - type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/neck_motors.pb.txt" - enable: true - } - devices { - id: "neck_arm" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/neck_arm.pb.txt" - enable: true + config_file: "devices/arm/lingkong_mixed_arm.pb.txt" + enable: false } } diff --git a/cmvr-es/config/tasks/quic_edge_task/quic_edge_task.pb.txt b/cmvr-es/config/tasks/quic_edge_task/quic_edge_task.pb.txt index 55703aed..20ec2e08 100644 --- a/cmvr-es/config/tasks/quic_edge_task/quic_edge_task.pb.txt +++ b/cmvr-es/config/tasks/quic_edge_task/quic_edge_task.pb.txt @@ -44,18 +44,6 @@ quic_edge { # } # } - platforms { - id: "platform_199" - server_host: "192.168.0.199" - server_port: 4433 - enable_media: false - tls { - ca_file: "certs/cmvr-quic-ca.crt" - server_name: "192.168.0.199" - allow_insecure: false - } - } - reconnect { initial_delay_ms: 500 maximum_delay_ms: 30000 diff --git a/cmvr-es/devices/arm/motor_robot_arm/include/motor_robot_arm.h b/cmvr-es/devices/arm/motor_robot_arm/include/motor_robot_arm.h index 73652d52..89f7ce34 100644 --- a/cmvr-es/devices/arm/motor_robot_arm/include/motor_robot_arm.h +++ b/cmvr-es/devices/arm/motor_robot_arm/include/motor_robot_arm.h @@ -177,6 +177,8 @@ private: int move_j_stable_sample_count_{3}; mutable std::mutex mutex_; + // Last successful arm-level enable/disable result; not live drive feedback. + std::atomic powered_on_{false}; std::atomic busy_{false}; std::atomic joint_motion_stop_generation_{0}; std::atomic speed_scaling_{1.0}; diff --git a/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm.cpp b/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm.cpp index da3ef663..a66fb9ab 100644 --- a/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm.cpp +++ b/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm.cpp @@ -163,8 +163,8 @@ ArmState MotorRobotArm::getRobotState() const const bool emergency_stopped = emergency_stopped_.load(); ArmState state; state.connected = motor_manager_ != nullptr; - state.powered_on = true; - state.brake_released = !emergency_stopped; + state.powered_on = powered_on_.load(); + state.brake_released = powered_on_.load() && !emergency_stopped; state.moving = busy(); state.protective_stopped = protective_stopped; state.emergency_stopped = emergency_stopped; @@ -272,6 +272,7 @@ Result MotorRobotArm::torqueOn() } } emergency_stopped_.store(false); + powered_on_.store(true); return Result::success(); } @@ -287,6 +288,7 @@ Result MotorRobotArm::torqueOff() "failed to torque off motor for joint: " + joint_name); } } + powered_on_.store(false); return Result::success(); } diff --git a/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm_gen2_mujoco_test.cpp b/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm_gen2_mujoco_test.cpp index 9feebb00..f8f2e288 100644 --- a/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm_gen2_mujoco_test.cpp +++ b/cmvr-es/devices/arm/motor_robot_arm/src/motor_robot_arm_gen2_mujoco_test.cpp @@ -869,3 +869,29 @@ TEST_F(MotorRobotArmGen2MujocoTest, SpeedL) } // namespace } // namespace cmvr::device + +namespace cmvr::device { +namespace { +TEST(MotorRobotArmPowerState, StartsDisabledAndFailedEnableStaysDisabled) { + config::RobotArmConfig cfg; + cfg.set_id("uninitialized_power_test"); + cfg.mutable_motor()->set_motor_system_id("missing_power_test"); + cfg.mutable_motor()->set_dof(1); + cfg.mutable_motor()->add_joint_names("missing_joint"); + MotorRobotArm arm(cfg); + EXPECT_FALSE(arm.getRobotState().powered_on); + EXPECT_FALSE(arm.torqueOn().ok()); + EXPECT_FALSE(arm.getRobotState().powered_on); +} +TEST_F(MotorRobotArmGen2MujocoTest, PowerStateTracksSuccessfulCommands) { + EXPECT_TRUE(arm_->getRobotState().powered_on); + const auto off = arm_->torqueOff(); + ASSERT_TRUE(off.ok()) << off.message; + EXPECT_FALSE(arm_->getRobotState().powered_on); + const auto on = arm_->torqueOn(); + ASSERT_TRUE(on.ok()) << on.message; + EXPECT_TRUE(arm_->getRobotState().powered_on); +} + +} // namespace +} // namespace cmvr::device