From 1c5a2bf33660e1f8fe8ed13c6290eefdb9aef076 Mon Sep 17 00:00:00 2001 From: AndyZe Date: Tue, 21 Apr 2026 11:29:59 -0500 Subject: [PATCH 1/2] Plan for 8 ethercat slaves --- include/elevated_control/interface_arm.hpp | 7 +++++- include/elevated_control/interface_base.hpp | 5 ++++ src/interface_base.cpp | 26 +++++++++++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/include/elevated_control/interface_arm.hpp b/include/elevated_control/interface_arm.hpp index f6eba18..2c11598 100644 --- a/include/elevated_control/interface_arm.hpp +++ b/include/elevated_control/interface_arm.hpp @@ -34,7 +34,12 @@ class ArmInterface : public SynapticonBase { public: struct Config : SynapticonBaseConfig { std::string elevate_config_yaml = "/home/elevate/Desktop/elevate_config.yaml"; - Config() { expected_slave_count = kNumJoints; } + Config() { + // Bus layout: positions 1..kNumJoints are SOMANET joint drives, and the + // final slave is the user-interface device (not a joint). + expected_slave_count = kNumJoints + 1; + num_joints = kNumJoints; + } }; explicit ArmInterface(const Config& config); diff --git a/include/elevated_control/interface_base.hpp b/include/elevated_control/interface_base.hpp index f830aec..f45caad 100644 --- a/include/elevated_control/interface_base.hpp +++ b/include/elevated_control/interface_base.hpp @@ -40,6 +40,11 @@ struct InSomanetSnapshot { struct SynapticonBaseConfig { std::string network_interface = "eno0"; std::size_t expected_slave_count = 0; // 0 = auto-detect, >0 = verify + // Number of joint slaves on the bus. Joints are assumed to occupy EtherCAT + // positions 1..num_joints; any additional trailing slaves (e.g. a + // user-interface device) are left alone by the driver. 0 = use total slave + // count (every detected slave is treated as a joint). + std::size_t num_joints = 0; std::string joint_limits_yaml; }; diff --git a/src/interface_base.cpp b/src/interface_base.cpp index 94601d3..15e43e7 100644 --- a/src/interface_base.cpp +++ b/src/interface_base.cpp @@ -155,14 +155,24 @@ std::expected SynapticonBase::Initialize() { Error{ErrorCode::kEtherCATError, "No EtherCAT slaves found"}); } - num_joints_ = static_cast(ec_slavecount); + const std::size_t total_slaves = static_cast(ec_slavecount); if (base_config_.expected_slave_count > 0 && - num_joints_ != base_config_.expected_slave_count) { + total_slaves != base_config_.expected_slave_count) { ec_close(); return std::unexpected(Error{ ErrorCode::kEtherCATError, "Expected " + std::to_string(base_config_.expected_slave_count) + - " slaves but found " + std::to_string(num_joints_)}); + " slaves but found " + std::to_string(total_slaves)}); + } + num_joints_ = base_config_.num_joints > 0 ? base_config_.num_joints + : total_slaves; + if (num_joints_ > total_slaves) { + ec_close(); + return std::unexpected(Error{ + ErrorCode::kEtherCATError, + "Configured num_joints (" + std::to_string(num_joints_) + + ") exceeds detected slave count (" + std::to_string(total_slaves) + + ")"}); } // Resize all per-joint containers @@ -335,7 +345,15 @@ std::expected SynapticonBase::Initialize() { }); initialized_ = true; - spdlog::info("SynapticonBase initialized with {} joints", num_joints_); + const std::size_t total_slaves = static_cast(ec_slavecount); + if (total_slaves == num_joints_) { + spdlog::info("SynapticonBase initialized with {} joints", num_joints_); + } else { + spdlog::info( + "SynapticonBase initialized with {} joints ({} total EtherCAT slaves, " + "{} trailing non-joint slave(s))", + num_joints_, total_slaves, total_slaves - num_joints_); + } return {}; } From b6e214a16451a6c2228482649b1eeaaafc7222fb Mon Sep 17 00:00:00 2001 From: AndyZe Date: Tue, 21 Apr 2026 11:35:16 -0500 Subject: [PATCH 2/2] Compilation fixup --- src/interface_base.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/interface_base.cpp b/src/interface_base.cpp index 15e43e7..d6fdb8e 100644 --- a/src/interface_base.cpp +++ b/src/interface_base.cpp @@ -345,7 +345,6 @@ std::expected SynapticonBase::Initialize() { }); initialized_ = true; - const std::size_t total_slaves = static_cast(ec_slavecount); if (total_slaves == num_joints_) { spdlog::info("SynapticonBase initialized with {} joints", num_joints_); } else {