From ee461e656b98f83d1ad5306e0922ff11bd0b631e Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Mon, 6 Jul 2026 22:13:37 +0800 Subject: [PATCH 01/24] Add option for admittance mode --- .../aic_flowstate_ros_bridge.proto | 2 + ..._flowstate_ros_bridge_default_config.pbtxt | 2 + .../config/default_joint_task_settings.pbtxt | 8 ++-- .../config/default_task_settings.pbtxt | 2 +- .../launch/aic_flowstate_ros_bridge_launch.py | 20 ++++++++-- .../src/aic_flowstate_ros_bridge_main.cpp | 4 ++ .../src/robot_control_bridge.cpp | 37 +++++++++++++++++-- .../src/robot_control_bridge.hpp | 1 + 8 files changed, 64 insertions(+), 12 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto index 010354560..3a159a211 100644 --- a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto +++ b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto @@ -10,6 +10,8 @@ message RobotControlBridgeConfig { string ft_sensor_part_name = 4; string task_settings_file = 5; string joint_task_settings_file = 6; + double time_to_target_seconds = 7; + string control_mode = 8; } message ToolTransformationConfig { diff --git a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt index 7347aeb9d..78900ecf9 100644 --- a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt @@ -52,5 +52,7 @@ ft_sensor_part_name: "ati" task_settings_file: "config/default_task_settings.pbtxt" joint_task_settings_file: "config/default_joint_task_settings.pbtxt" + time_to_target_seconds: 0.1 + control_mode: "admittance" }, } diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt index 6396ced09..0d8591d4b 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt @@ -6,13 +6,13 @@ damping_smoothing_constant: 0.1 # These limits cannot exceed the application limits. joint_limits_update: { - min_position: { values: [-6.22, -4.059, -2.77, -6.22, -6.22, -6.22] } - max_position: { values: [6.22, 0.95, 2.77, 6.22, 6.22, 6.22] } + min_position: { values: [-6.22, -4.059, -2.77, -6.22, -6.22, 1.571] } + max_position: { values: [6.22, 0.95, 2.77, 6.22, 6.22, 4.712] } # For safety/testing, reducing velocity limits is usually the most intuitive # and all that matters for conservative motion. Reducting acceleration and # jerk limits can have counter-intuitive behavior. - max_velocity: { values: [0.8, 0.8, 0.8, 0.8, 0.8, 0.8] } - max_acceleration: { values: [10, 10, 10, 10, 10, 10] } + max_velocity: { values: [0.746, 0.746, 0.746, 0.746, 0.746, 0.746] } + max_acceleration: { values: [5, 5, 5, 5, 5, 5] } max_jerk: { values: [8001, 8001, 8001, 8001, 8001, 8001] } max_effort: { values: [100.0, 100.0, 100.0, 28.0, 28.0, 28.0] } } diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index 899930dc4..76a932124 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -102,4 +102,4 @@ pose_error_integrator_bound: { x: 10 y: 10 z: 10 rx: 2 ry: 2 rz: 2 } # The control mode allows switching between impedance and admittance control, # and defaults to impedance control when not specified. -control_mode: IMPEDANCE \ No newline at end of file +control_mode: ADMITTANCE \ No newline at end of file diff --git a/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py b/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py index 70342a51d..e4f9fd989 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py @@ -76,6 +76,16 @@ def generate_launch_description(): default_value="ati", description="F/T sensor part name", ), + DeclareLaunchArgument( + "control_mode", + default_value="admittance", + description="Control mode (admittance or impedance)", + ), + DeclareLaunchArgument( + "time_to_target_seconds", + default_value="0.1", + description="Time to reach target in seconds", + ), DeclareLaunchArgument( "use_sim_time", default_value="true", @@ -96,10 +106,10 @@ def generate_launch_description(): "flowstate_zenoh_router_address" ), "bridge_plugins": [ - "flowstate_ros_bridge::ExecutiveBridge", - "flowstate_ros_bridge::WorldBridge", + # "flowstate_ros_bridge::ExecutiveBridge", + # "flowstate_ros_bridge::WorldBridge", "flowstate_ros_bridge::RobotControlBridge", - "flowstate_ros_bridge::AicCameraBridge", + # "flowstate_ros_bridge::AicCameraBridge", ], "server_address": LaunchConfiguration("server_address"), "instance": LaunchConfiguration("instance"), @@ -125,6 +135,10 @@ def generate_launch_description(): "config", "default_joint_task_settings.pbtxt", ), + "control_mode": LaunchConfiguration("control_mode"), + "time_to_target_seconds": LaunchConfiguration( + "time_to_target_seconds" + ), "override_joint_names": [ "shoulder_pan_joint", "shoulder_lift_joint", diff --git a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp index b5efa9da0..f7288d835 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp @@ -137,6 +137,10 @@ int main(int argc, char* argv[]) { robot_control_bridge_config.task_settings_file()); params.emplace_back("joint_task_settings_file", robot_control_bridge_config.joint_task_settings_file()); + params.emplace_back("time_to_target_seconds", + robot_control_bridge_config.time_to_target_seconds()); + params.emplace_back("control_mode", + robot_control_bridge_config.control_mode()); const auto& override_joint_names_proto = s.override_joint_names(); std::vector override_joint_names( override_joint_names_proto.begin(), override_joint_names_proto.end()); diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 0de32ea75..308466b48 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -58,6 +58,9 @@ constexpr const char* kFlowstateZenohRouterParamName = "flowstate_zenoh_router_address"; constexpr const char* kRestartConnectionRetriesParamName = "restart_connection_retries"; +constexpr const char* kTimeToTargetSecondsParamName = + "time_to_target_seconds"; +constexpr const char* kControlModeParamName = "control_mode"; ///============================================================================= void RobotControlBridge::declare_ros_parameters( @@ -80,6 +83,10 @@ void RobotControlBridge::declare_ros_parameters( rclcpp::ParameterValue{""}); param_interface->declare_parameter(kRestartConnectionRetriesParamName, rclcpp::ParameterValue{10}); + param_interface->declare_parameter(kTimeToTargetSecondsParamName, + rclcpp::ParameterValue{0.1}); + param_interface->declare_parameter(kControlModeParamName, + rclcpp::ParameterValue{"admittance"}); } ///============================================================================= @@ -108,6 +115,12 @@ bool RobotControlBridge::initialize( data_->restart_connection_retries_ = param_interface->get_parameter(kRestartConnectionRetriesParamName) .get_value(); + data_->time_to_target_seconds_ = + param_interface->get_parameter(kTimeToTargetSecondsParamName) + .get_value(); + std::string control_mode_str = + param_interface->get_parameter(kControlModeParamName) + .get_value(); std::filesystem::path task_settings_file = param_interface->get_parameter(kAgentBridgeTaskSettingsFileParamName) .get_value(); @@ -169,6 +182,18 @@ bool RobotControlBridge::initialize( "filepath for loading default task_settings."; throw std::runtime_error("'joint_task_settings_file' parameter is empty."); } + + if (control_mode_str == "admittance") { + data_->agent_bridge_fixed_params_.mutable_task_settings()->set_control_mode( + intrinsic_proto::icon::actions::proto::ControlMode::ADMITTANCE); + } else if (control_mode_str == "impedance") { + data_->agent_bridge_fixed_params_.mutable_task_settings()->set_control_mode( + intrinsic_proto::icon::actions::proto::ControlMode::IMPEDANCE); + } else { + LOG(ERROR) << "Invalid control_mode: " << control_mode_str; + throw std::runtime_error("Invalid control_mode parameter."); + } + // Set default taring cycle of 100 // todo(johntgz) set this as a ros parameter data_->tare_ft_sensor_fixed_params_.set_num_taring_cycles(100); @@ -679,14 +704,18 @@ bool RobotControlBridge::startControllerAction() { ActionDescriptor agent_bridge_descriptor = ActionDescriptor( intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, - {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}}) + {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}, + {intrinsic::icon::AgentBridgeInfo::kForceTorqueSlotName, + data_->ft_sensor_part_name_}}) .WithFixedParams(data_->agent_bridge_fixed_params_); ActionDescriptor agent_bridge_joint_descriptor = ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, kAgentBridgeJointId, {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, - data_->part_name_}}) + data_->part_name_}, + {intrinsic::icon::AgentBridgeJointInfo::kForceTorqueSlotName, + data_->ft_sensor_part_name_}}) .WithFixedParams(data_->agent_bridge_joint_fixed_params_); ActionDescriptor tare_ft_sensor_descriptor = @@ -1122,7 +1151,7 @@ void RobotControlBridge::MotionUpdateCallback( // Set time_to_target_seconds to a default of 1.1 * controller period (0.002 // s), so it will reach the target as fast as possible - proto_msg.set_time_to_target_seconds(0.0022); + proto_msg.set_time_to_target_seconds(data_->time_to_target_seconds_); // Write the MotionUpdate proto message to the AgentBridge action auto status = data_->agent_bridge_writer_->Write(proto_msg); @@ -1211,7 +1240,7 @@ void RobotControlBridge::JointMotionUpdateCallback( // Set time_to_target_seconds to a default of 1.1 * controller period (0.002 // s), so it will reach the target as fast as possible - proto_msg.set_time_to_target_seconds(0.0022); + proto_msg.set_time_to_target_seconds(data_->time_to_target_seconds_); // Write the JointMotionUpdate proto message to the AgentBridgeJoint action auto status = data_->agent_bridge_joint_writer_->Write(proto_msg); diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp index 08ed23ef9..942641ccc 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp @@ -217,6 +217,7 @@ class RobotControlBridge : public BridgeInterface { int restart_connection_retries_; uint8_t target_mode_value_; std::optional last_part_status_timestamp_ns_; + double time_to_target_seconds_; aic_control_interfaces::msg::ControllerState controller_state_; std::mutex controller_state_mutex_; From 1c28bdbfb7dcf70753c45cf71f242c7d6596bc83 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 8 Jul 2026 22:39:29 +0800 Subject: [PATCH 02/24] add mass_for_critical_damping parameter --- .../aic_flowstate_ros_bridge.proto | 1 + ..._flowstate_ros_bridge_default_config.pbtxt | 1 + .../launch/aic_flowstate_ros_bridge_launch.py | 6 ++-- .../src/aic_flowstate_ros_bridge_main.cpp | 4 +++ .../src/robot_control_bridge.cpp | 34 +++++++++++-------- .../src/robot_control_bridge.hpp | 1 + 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto index 3a159a211..224860bc9 100644 --- a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto +++ b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge.proto @@ -12,6 +12,7 @@ message RobotControlBridgeConfig { string joint_task_settings_file = 6; double time_to_target_seconds = 7; string control_mode = 8; + repeated double critical_mass = 9; } message ToolTransformationConfig { diff --git a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt index 78900ecf9..df2864f52 100644 --- a/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/aic_flowstate_ros_bridge_default_config.pbtxt @@ -54,5 +54,6 @@ joint_task_settings_file: "config/default_joint_task_settings.pbtxt" time_to_target_seconds: 0.1 control_mode: "admittance" + critical_mass: [10.0, 10.0, 10.0, 5.0, 5.0, 5.0] }, } diff --git a/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py b/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py index e4f9fd989..eca1ca187 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/aic_flowstate_ros_bridge_launch.py @@ -106,10 +106,10 @@ def generate_launch_description(): "flowstate_zenoh_router_address" ), "bridge_plugins": [ - # "flowstate_ros_bridge::ExecutiveBridge", - # "flowstate_ros_bridge::WorldBridge", + "flowstate_ros_bridge::ExecutiveBridge", + "flowstate_ros_bridge::WorldBridge", "flowstate_ros_bridge::RobotControlBridge", - # "flowstate_ros_bridge::AicCameraBridge", + "flowstate_ros_bridge::AicCameraBridge", ], "server_address": LaunchConfiguration("server_address"), "instance": LaunchConfiguration("instance"), diff --git a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp index f7288d835..c5fa5b49a 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp @@ -141,6 +141,10 @@ int main(int argc, char* argv[]) { robot_control_bridge_config.time_to_target_seconds()); params.emplace_back("control_mode", robot_control_bridge_config.control_mode()); + + const auto& critical_mass_proto = robot_control_bridge_config.critical_mass(); + std::vector critical_mass(critical_mass_proto.begin(), critical_mass_proto.end()); + params.emplace_back("critical_mass", critical_mass); const auto& override_joint_names_proto = s.override_joint_names(); std::vector override_joint_names( override_joint_names_proto.begin(), override_joint_names_proto.end()); diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 308466b48..5969e9f8a 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -61,6 +61,7 @@ constexpr const char* kRestartConnectionRetriesParamName = constexpr const char* kTimeToTargetSecondsParamName = "time_to_target_seconds"; constexpr const char* kControlModeParamName = "control_mode"; +constexpr const char* kCriticalMassParamName = "critical_mass"; ///============================================================================= void RobotControlBridge::declare_ros_parameters( @@ -87,6 +88,9 @@ void RobotControlBridge::declare_ros_parameters( rclcpp::ParameterValue{0.1}); param_interface->declare_parameter(kControlModeParamName, rclcpp::ParameterValue{"admittance"}); + param_interface->declare_parameter( + kCriticalMassParamName, + rclcpp::ParameterValue{std::vector{5.0, 5.0, 5.0, 5.0, 5.0, 5.0}}); } ///============================================================================= @@ -118,6 +122,9 @@ bool RobotControlBridge::initialize( data_->time_to_target_seconds_ = param_interface->get_parameter(kTimeToTargetSecondsParamName) .get_value(); + data_->critical_mass_ = + param_interface->get_parameter(kCriticalMassParamName) + .get_value>(); std::string control_mode_str = param_interface->get_parameter(kControlModeParamName) .get_value(); @@ -893,16 +900,11 @@ bool RobotControlBridge::resetMotionUpdate() { target_mass->mutable_data()->Resize(36, 0.0); if (data_->agent_bridge_fixed_params_.task_settings().has_max_stiffness() && - data_->agent_bridge_fixed_params_.task_settings().has_max_damping() && - data_->agent_bridge_fixed_params_.task_settings() - .has_mass_for_critical_damping()) { + data_->agent_bridge_fixed_params_.task_settings().has_max_damping()) { const auto& max_stiffness = data_->agent_bridge_fixed_params_.task_settings().max_stiffness(); const auto& max_damping = data_->agent_bridge_fixed_params_.task_settings().max_damping(); - const auto& critical_mass = - data_->agent_bridge_fixed_params_.task_settings() - .mass_for_critical_damping(); target_stiffness->set_data(0, max_stiffness.x()); target_stiffness->set_data(7, max_stiffness.y()); @@ -918,15 +920,19 @@ bool RobotControlBridge::resetMotionUpdate() { target_damping->set_data(28, max_damping.ry()); target_damping->set_data(35, max_damping.rz()); - target_mass->set_data(0, critical_mass.x()); - target_mass->set_data(7, critical_mass.y()); - target_mass->set_data(14, critical_mass.z()); - target_mass->set_data(21, critical_mass.rx()); - target_mass->set_data(28, critical_mass.ry()); - target_mass->set_data(35, critical_mass.rz()); + if (data_->critical_mass_.size() >= 6) { + target_mass->set_data(0, data_->critical_mass_[0]); + target_mass->set_data(7, data_->critical_mass_[1]); + target_mass->set_data(14, data_->critical_mass_[2]); + target_mass->set_data(21, data_->critical_mass_[3]); + target_mass->set_data(28, data_->critical_mass_[4]); + target_mass->set_data(35, data_->critical_mass_[5]); + } else { + LOG(ERROR) << "critical_mass parameter does not have 6 elements."; + return false; + } } else { - LOG(ERROR) << "Task settings missing max_stiffness, max_damping, or " - "mass_for_critical_damping parameters."; + LOG(ERROR) << "Task settings missing max_stiffness or max_damping parameters."; return false; } diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp index 942641ccc..628b2d79e 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp @@ -218,6 +218,7 @@ class RobotControlBridge : public BridgeInterface { uint8_t target_mode_value_; std::optional last_part_status_timestamp_ns_; double time_to_target_seconds_; + std::vector critical_mass_; aic_control_interfaces::msg::ControllerState controller_state_; std::mutex controller_state_mutex_; From 03bef8b574ee87c3f721b8746a133b497a06e385 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 8 Jul 2026 22:39:45 +0800 Subject: [PATCH 03/24] add test script for admittance control --- .../test_robot_control_bridge.launch.py | 79 +++++++ .../scripts/test_robot_control_bridge.py | 213 ++++++++++-------- 2 files changed, 192 insertions(+), 100 deletions(-) create mode 100644 flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py new file mode 100644 index 000000000..49839f4cf --- /dev/null +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py @@ -0,0 +1,79 @@ +import launch +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + return LaunchDescription([ + Node( + package='aic_flowstate_ros_bridge', + executable='test_robot_control_bridge.py', + name='test_robot_control_bridge_node', + output='screen', + parameters=[ + { + 'controller_namespace': 'aic_controller', + # Example test_pose_targets format: JSON string of a flattened list of poses (or list of lists). + # The list is automatically chunked into 7 elements per pose: [x, y, z, qx, qy, qz, qw] + ########################## + # Home position + ########################## + 'test_pose_targets': '[' + '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + ']', + ########################## + # Test 1 (position): + ########################## + # 'test_pose_targets': '[' + # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + ########################## + # Test 2 (pose): + ########################## + # 'test_pose_targets': '[' + # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #A: +45 x + # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #A: -45 x + # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #A: +45 y + # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #A: -45 y + # #### + # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #B: +45 x + # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #B: -45 x + # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #B: +45 y + # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #B: -45 y + # #### + # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #C: +45 x + # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #C: -45 x + # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #C: +45 y + # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #C: -45 y + # #### + # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #D: +45 x + # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #D: -45 x + # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #D: +45 y + # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #D: -45 y + # #### + # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #E: +45 x + # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #E: -45 x + # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #E: +45 y + # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #E: -45 y + # #### + # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, ' #F: +45 x + # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, ' #F: -45 x + # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, ' #F: +45 y + # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #F: -45 y + # #### + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home + # ']', + 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json + 'target_stiffness': [1000.0, 150.0], + 'target_damping': [200.0, 54.7723], + 'publish_duration': 5.0, + 'stop_duration': 2.0 + } + ] + ) + ]) diff --git a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py index e9d00976d..83b37728c 100755 --- a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py +++ b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py @@ -18,6 +18,8 @@ import sys import time +import json +from datetime import datetime import rclpy import numpy as np from rclpy.executors import ExternalShutdownException @@ -25,14 +27,14 @@ from rclpy.node import Node from aic_control_interfaces.msg import ( MotionUpdate, - JointMotionUpdate, + ControllerState, TrajectoryGenerationMode, TargetMode, ) from aic_control_interfaces.srv import ( ChangeTargetMode, ) -from geometry_msgs.msg import Pose, Point, Quaternion, Wrench, Vector3, Twist +from geometry_msgs.msg import Pose, Point, Quaternion, Wrench, Vector3, Twist, WrenchStamped class TestRobotControlBridgeNode(Node): @@ -45,6 +47,53 @@ def __init__(self): "controller_namespace", "aic_controller" ).value + self.test_pose_targets_str = self.declare_parameter( + "test_pose_targets", "[]" + ).value + + + self.log_filepath = self.declare_parameter( + "log_filepath", "" + ).value + + stiffness_param = self.declare_parameter( + "target_stiffness", [10.0, 10.0] + ).value + self.target_stiffness = [stiffness_param[0]] * 3 + [stiffness_param[1]] * 3 + + damping_param = self.declare_parameter( + "target_damping", [5.0, 5.0] + ).value + self.target_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 + + self.publish_duration = self.declare_parameter( + "publish_duration", 5.0 + ).value + + self.stop_duration = self.declare_parameter( + "stop_duration", 5.0 + ).value + + parsed_targets = json.loads(self.test_pose_targets_str) + if parsed_targets and not isinstance(parsed_targets[0], list): + # Reshape 1D array into 2D array of poses (7 elements each) + self.test_pose_targets = [ + parsed_targets[i : i + 7] + for i in range(0, len(parsed_targets), 7) + ] + else: + self.test_pose_targets = parsed_targets + + self.tcp_error = None + self.latest_wrench = None + + self.wrench_subscriber = self.create_subscription( + WrenchStamped, + "/fts_broadcaster/wrench", + self.wrench_callback, + 10 + ) + self.motion_update_publisher = self.create_publisher( MotionUpdate, f"/{self.controller_namespace}/pose_commands", 10 ) @@ -55,18 +104,13 @@ def __init__(self): ) time.sleep(1.0) - self.joint_motion_update_publisher = self.create_publisher( - JointMotionUpdate, - f"/{self.controller_namespace}/joint_commands", - 10, + self.state_subscriber = self.create_subscription( + ControllerState, + f"/{self.controller_namespace}/controller_state", + self.state_callback, + 10 ) - while self.joint_motion_update_publisher.get_subscription_count() == 0: - self.get_logger().info( - f"Waiting for subscriber to '{self.controller_namespace}/joint_commands'..." - ) - time.sleep(1.0) - self.client = self.create_client( ChangeTargetMode, f"/{self.controller_namespace}/change_target_mode" ) @@ -78,6 +122,19 @@ def __init__(self): ) time.sleep(1.0) + def state_callback(self, msg: ControllerState): + self.tcp_error = list(msg.tcp_error) + + def wrench_callback(self, msg: WrenchStamped): + self.latest_wrench = [ + msg.wrench.force.x, + msg.wrench.force.y, + msg.wrench.force.z, + msg.wrench.torque.x, + msg.wrench.torque.y, + msg.wrench.torque.z, + ] + def generate_motion_update( self, pos, @@ -100,8 +157,8 @@ def generate_motion_update( linear=Vector3(x=twist[0], y=twist[1], z=twist[2]), angular=Vector3(x=twist[3], y=twist[4], z=twist[5]), ) - msg.target_stiffness = np.diag([75.0, 75.0, 75.0, 75.0, 75.0, 75.0]).flatten() - msg.target_damping = np.diag([35.0, 35.0, 35.0, 35.0, 35.0, 35.0]).flatten() + msg.target_stiffness = np.diag(self.target_stiffness).flatten() + msg.target_damping = np.diag(self.target_damping).flatten() msg.feedforward_wrench_at_tip = Wrench( force=Vector3(x=0.0, y=0.0, z=0.0), torque=Vector3(x=0.0, y=0.0, z=0.0), @@ -111,16 +168,6 @@ def generate_motion_update( return msg - def generate_joint_motion_update(self, joint_pos): - msg = JointMotionUpdate() - - msg.target_state.positions = joint_pos - msg.target_stiffness = [100, 100, 100, 100, 150, 150] - msg.target_damping = [30, 30, 20, 20, 4, 4] - msg.trajectory_generation_mode.mode = TrajectoryGenerationMode.MODE_POSITION - - return msg - def send_cartesian_pose_target(self, pos, quat, frame_id): self.motion_update_publisher.publish( @@ -128,28 +175,6 @@ def send_cartesian_pose_target(self, pos, quat, frame_id): pos, quat, frame_id, TrajectoryGenerationMode.MODE_POSITION ) ) - self.get_logger().info( - f"Published MotionUpdate with POSITION trajectory mode to aic_controller" - ) - - def send_cartesian_twist_target(self, twist, frame_id): - - self.motion_update_publisher.publish( - self.generate_motion_update( - None, None, frame_id, TrajectoryGenerationMode.MODE_VELOCITY, twist - ) - ) - self.get_logger().info( - f"Published MotionUpdate with VELOCITY trajectory mode to aic_controller" - ) - - def send_joint_target(self, joint_pos): - - self.joint_motion_update_publisher.publish( - self.generate_joint_motion_update(joint_pos) - ) - - self.get_logger().info("Published JointMotionUpdate to aic_controller") def send_change_target_mode_req(self, mode): @@ -179,63 +204,51 @@ def main(args=None): node = TestRobotControlBridgeNode() try: - quat_tool_down = [ - 0.7071068, - 0.7071068, - 0.0, - 0.0, - ] # ZYX = (180, 0, 90), z axis normal to plane and (x,y) axes are aligned with base_link axes - - # Trigger reconection - node.send_cartesian_pose_target( - [-0.501, -0.175, 0.2], - quat_tool_down, - "base_link", - ) - time.sleep(3) - # Send service request to switch to Cartesian target mode node.send_change_target_mode_req(TargetMode.MODE_CARTESIAN) - # Send Cartesian pose targets in both "base_link" and "gripper/tcp" frames - node.send_cartesian_pose_target( - [-0.501, -0.175, 0.2], - quat_tool_down, - "base_link", - ) - time.sleep(5) - - node.send_cartesian_pose_target( - [-0.501, -0.175, 0.5], - [-0.2126311, 0.2126311, 0.6743797, 0.6743797], - "base_link", - ) - time.sleep(5) - - # Send Cartesian twist targets in both "base_link" and "gripper/tcp" frames - node.send_cartesian_twist_target( - [0.05, 0.0, 0.0, 0.0, 0.0, 0.0], - "base_link", - ) - time.sleep(3) - node.send_cartesian_twist_target( - [0.0, -0.05, 0.0, 0.0, 0.0, 0.0], - "gripper/tcp", - ) - time.sleep(3) - - # Send service request to switch to joint target mode - node.send_change_target_mode_req(TargetMode.MODE_JOINT) - - node.send_joint_target([0.5, -1.25, -1.5, -1.5, 1.0, 1.0]) - time.sleep(5) - - node.send_joint_target( - [0.0, -1.354375, -1.6648696, -1.6931439, 1.5708, 1.4109242] - ) - time.sleep(5) - - rclpy.spin(node) + output_log = { + "target_stiffness": node.target_stiffness, + "target_damping": node.target_damping, + "results": {} + } + + for pose in node.test_pose_targets: + # pose is expected to be [x, y, z, qx, qy, qz, qw] + pos = pose[0:3] + quat = pose[3:7] + + node.get_logger().info(f"Testing pose target: {pose}") + + node.get_logger().info(f"Publishing motion update for {node.publish_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.publish_duration and rclpy.ok(): + node.send_cartesian_pose_target(pos, quat, "base_link") + rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz + + node.get_logger().info(f"Stopping motion updates for {node.stop_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.stop_duration and rclpy.ok(): + rclpy.spin_once(node, timeout_sec=0.1) + + if node.tcp_error is not None: + node.get_logger().info(f"Recording tcp_error: {node.tcp_error}") + recorded_data = {"tcp_error": node.tcp_error} + if node.latest_wrench is not None: + node.get_logger().info(f"Recording wrench: {node.latest_wrench}") + recorded_data["wrench"] = node.latest_wrench + output_log["results"][str(pose)] = recorded_data + + if output_log["results"]: + if node.log_filepath: + filename = node.log_filepath + else: + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"tcp_accuracy_{timestamp}.json" + + with open(filename, "w") as f: + json.dump(output_log, f, indent=4) + node.get_logger().info(f"Saved TCP accuracy to {filename}") except (KeyboardInterrupt, ExternalShutdownException): pass From ca44018fb9c016a4278916fdc25012cc0bf474e3 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 8 Jul 2026 22:40:00 +0800 Subject: [PATCH 04/24] increase cartesian translational limits --- .../config/default_task_settings.pbtxt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index 76a932124..ef5016be6 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -6,7 +6,7 @@ # with critical damping under the assume mass. max_stiffness: { x: 800 y: 800 z: 800 rx: 40 ry: 40 rz: 40 } max_damping: { x: 76 y: 76 z: 76 rx: 10 ry: 10 rz: 10 } -mass_for_critical_damping: { x: 1.8 y: 1.8 z: 1.8 rx: 0.12 ry: 0.12 rz: 0.12 } +mass_for_critical_damping: { x: 10.0 y: 10.0 z: 10.0 rx: 5.0 ry: 5.0 rz: 5.0 } # Limits of a reasonable retangular volume in front the the robot. This should # be adjusted for different workcells and even different applications. @@ -18,12 +18,12 @@ cartesian_limits { max_translational_position: 1.0 # y max_translational_position: 1.5 # z - min_translational_velocity: -0.3 - min_translational_velocity: -0.3 - min_translational_velocity: -0.3 - max_translational_velocity: 0.3 - max_translational_velocity: 0.3 - max_translational_velocity: 0.3 + min_translational_velocity: -1.0 + min_translational_velocity: -1.0 + min_translational_velocity: -1.0 + max_translational_velocity: 1.0 + max_translational_velocity: 1.0 + max_translational_velocity: 1.0 min_translational_acceleration: -10 min_translational_acceleration: -10 @@ -39,7 +39,7 @@ cartesian_limits { max_translational_jerk: 3000.0 max_translational_jerk: 3000.0 - max_rotational_velocity: 1 + max_rotational_velocity: 2 max_rotational_acceleration: 10 max_rotational_jerk: 3000.0 } @@ -102,4 +102,6 @@ pose_error_integrator_bound: { x: 10 y: 10 z: 10 rx: 2 ry: 2 rz: 2 } # The control mode allows switching between impedance and admittance control, # and defaults to impedance control when not specified. -control_mode: ADMITTANCE \ No newline at end of file +control_mode: ADMITTANCE + +sensed_wrench_deadband { x: 0.2 y: 0.2 z: 0.5 rx: 0.05 ry: 0.05 rz: 0.05 } From ca81cf504cde49850680b03852103d416f813f29 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 14 Jul 2026 10:34:51 +0800 Subject: [PATCH 05/24] accomodate actions with and without force torque sensors --- .../test_robot_control_bridge.launch.py | 30 +++---- .../src/robot_control_bridge.cpp | 85 ++++++++++++------- .../src/robot_control_bridge.hpp | 2 +- 3 files changed, 69 insertions(+), 48 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py index 49839f4cf..b48225c91 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py @@ -17,22 +17,22 @@ def generate_launch_description(): ########################## # Home position ########################## - 'test_pose_targets': '[' - '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - ']', - ########################## - # Test 1 (position): - ########################## # 'test_pose_targets': '[' - # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # ']', ########################## + # Test 1 (position): + ########################## + 'test_pose_targets': '[' + '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + ']', + ########################## # Test 2 (pose): ########################## # 'test_pose_targets': '[' @@ -69,9 +69,9 @@ def generate_launch_description(): # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home # ']', 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json - 'target_stiffness': [1000.0, 150.0], - 'target_damping': [200.0, 54.7723], - 'publish_duration': 5.0, + 'target_stiffness': [1500.0, 150.0], + 'target_damping': [100.0, 15.0], + 'publish_duration': 3.0, 'stop_duration': 2.0 } ] diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 5969e9f8a..4dde55051 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -77,7 +77,7 @@ void RobotControlBridge::declare_ros_parameters( param_interface->declare_parameter(kPartNameParamName, rclcpp::ParameterValue{"arm"}); param_interface->declare_parameter(kFTPartNameParamName, - rclcpp::ParameterValue{"ft_sensor"}); + rclcpp::ParameterValue{""}); param_interface->declare_parameter(kAgentBridgeTaskSettingsFileParamName, rclcpp::ParameterValue{""}); param_interface->declare_parameter(kAgentBridgeJointTaskSettingsFileParamName, @@ -113,9 +113,14 @@ bool RobotControlBridge::initialize( .get_value(); data_->part_name_ = param_interface->get_parameter(kPartNameParamName) .get_value(); - data_->ft_sensor_part_name_ = + std::string param_ft_sensor_part_name = param_interface->get_parameter(kFTPartNameParamName) .get_value(); + if (!param_ft_sensor_part_name.empty()) { + data_->ft_sensor_part_name_ = param_ft_sensor_part_name; + } else { + data_->ft_sensor_part_name_ = std::nullopt; + } data_->restart_connection_retries_ = param_interface->get_parameter(kRestartConnectionRetriesParamName) .get_value(); @@ -709,30 +714,32 @@ bool RobotControlBridge::startControllerAction() { // Define ActionDescriptors for both the AgentBridge and AgentBridgeJoint // actions ActionDescriptor agent_bridge_descriptor = - ActionDescriptor( - intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, - {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}, - {intrinsic::icon::AgentBridgeInfo::kForceTorqueSlotName, - data_->ft_sensor_part_name_}}) - .WithFixedParams(data_->agent_bridge_fixed_params_); + data_->ft_sensor_part_name_.has_value() + ? ActionDescriptor( + intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, + {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}, + {intrinsic::icon::AgentBridgeInfo::kForceTorqueSlotName, + data_->ft_sensor_part_name_.value()}}) + .WithFixedParams(data_->agent_bridge_fixed_params_) + : ActionDescriptor( + intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, + {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}}) + .WithFixedParams(data_->agent_bridge_fixed_params_); ActionDescriptor agent_bridge_joint_descriptor = - ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, - kAgentBridgeJointId, - {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, - data_->part_name_}, - {intrinsic::icon::AgentBridgeJointInfo::kForceTorqueSlotName, - data_->ft_sensor_part_name_}}) - .WithFixedParams(data_->agent_bridge_joint_fixed_params_); - - ActionDescriptor tare_ft_sensor_descriptor = - ActionDescriptor( - intrinsic::icon::TareForceTorqueSensorInfo::kActionTypeName, - kTareForceTorqueSensorId, - {{intrinsic::icon::TareForceTorqueSensorInfo:: - kForceTorqueSensorSlotName, - data_->ft_sensor_part_name_}}) - .WithFixedParams(data_->tare_ft_sensor_fixed_params_); + data_->ft_sensor_part_name_.has_value() + ? ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, + kAgentBridgeJointId, + {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, + data_->part_name_}, + {intrinsic::icon::AgentBridgeJointInfo::kForceTorqueSlotName, + data_->ft_sensor_part_name_.value()}}) + .WithFixedParams(data_->agent_bridge_joint_fixed_params_) + : ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, + kAgentBridgeJointId, + {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, + data_->part_name_}}) + .WithFixedParams(data_->agent_bridge_joint_fixed_params_); // Add the AgentBridge and AgentBridgeJoint actions to the session, then // create StreamWriters for each of the actions. @@ -758,13 +765,26 @@ bool RobotControlBridge::startControllerAction() { data_->agent_bridge_joint_action_ = agent_bridge_joint_action_or.value(); // Add the TareForceTorqueSensor action to the current session - auto tare_action_or = data_->session_->AddAction(tare_ft_sensor_descriptor); - if (!tare_action_or.ok()) { - LOG(ERROR) << "Failed to add TareForceTorqueSensor Action: " - << tare_action_or.status().message().data(); - return false; + if (data_->ft_sensor_part_name_.has_value()) { + ActionDescriptor tare_ft_sensor_descriptor = + ActionDescriptor( + intrinsic::icon::TareForceTorqueSensorInfo::kActionTypeName, + kTareForceTorqueSensorId, + {{intrinsic::icon::TareForceTorqueSensorInfo:: + kForceTorqueSensorSlotName, + data_->ft_sensor_part_name_.value()}}) + .WithFixedParams(data_->tare_ft_sensor_fixed_params_); + + auto tare_action_or = data_->session_->AddAction(tare_ft_sensor_descriptor); + if (!tare_action_or.ok()) { + LOG(ERROR) << "Failed to add TareForceTorqueSensor Action: " + << tare_action_or.status().message().data(); + return false; + } + data_->tare_action_ = tare_action_or.value(); + } else { + data_->tare_action_ = std::nullopt; } - data_->tare_action_ = tare_action_or.value(); // Create StreamWriter for the AgentBridge action auto agent_bridge_writer_or = @@ -860,8 +880,9 @@ bool RobotControlBridge::startControllerSession() { // Start ICON Session std::vector parts = {data_->part_name_}; - if (data_->ft_sensor_part_name_ != data_->part_name_) { - parts.push_back(data_->ft_sensor_part_name_); + if (data_->ft_sensor_part_name_.has_value() && + data_->ft_sensor_part_name_.value() != data_->part_name_) { + parts.push_back(data_->ft_sensor_part_name_.value()); } auto session_or = Session::Start(icon_channel_or.value(), parts); diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp index 628b2d79e..8e19c45c0 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.hpp @@ -210,7 +210,7 @@ class RobotControlBridge : public BridgeInterface { bool connected_to_controller_; std::string part_name_; - std::string ft_sensor_part_name_; + std::optional ft_sensor_part_name_; std::string instance_; std::string server_address_; std::size_t num_joints_; From b8e609363e68f86d452ff8db2a0a54836e63dc10 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Mon, 20 Jul 2026 21:02:33 +0800 Subject: [PATCH 06/24] modify test_robot_control_bridge script for sending joint targets --- .../launch/test_joint_targets.launch.py | 38 ++++ ....launch.py => test_pose_targets.launch.py} | 33 +-- .../scripts/test_robot_control_bridge.py | 196 ++++++++++++++---- 3 files changed, 213 insertions(+), 54 deletions(-) create mode 100644 flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py rename flowstate/aic_flowstate_ros_bridge/launch/{test_robot_control_bridge.launch.py => test_pose_targets.launch.py} (79%) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py new file mode 100644 index 000000000..552c47746 --- /dev/null +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -0,0 +1,38 @@ +import launch +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + return LaunchDescription([ + Node( + package='aic_flowstate_ros_bridge', + executable='test_robot_control_bridge.py', + name='test_robot_control_bridge_node', + output='screen', + parameters=[ + { + 'controller_namespace': 'aic_controller', + 'test_mode': 'joint', + ########################## + # Home position: + ########################## + 'test_joint_targets': '[' + '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' + ']', + ########################## + # Position 1: + ########################## + # 'test_joint_targets': '[' + # '0.0, -0.785, 0.0, -2.356, 0.0, 1.571 ' + # ']', + 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json + 'target_pose_stiffness': [1000.0, 150.0], + 'target_pose_damping': [200.0, 54.7723], + 'target_joint_stiffness': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0], + 'target_joint_damping': [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], + 'publish_duration': 3.0, + 'stop_duration': 2.0 + } + ] + ) + ]) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py similarity index 79% rename from flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py rename to flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index b48225c91..4cef82b02 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_robot_control_bridge.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -12,26 +12,33 @@ def generate_launch_description(): parameters=[ { 'controller_namespace': 'aic_controller', + 'test_mode': 'pose', # Example test_pose_targets format: JSON string of a flattened list of poses (or list of lists). # The list is automatically chunked into 7 elements per pose: [x, y, z, qx, qy, qz, qw] ########################## # Home position ########################## + 'test_pose_targets': '[' + '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + ']', + ########################## + # Test contact + ########################## # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # '-0.1, -0.5, 0.16, 0.7071068, -0.7071068, 0.0, 0.0 ' # ']', ########################## # Test 1 (position): ########################## - 'test_pose_targets': '[' - '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - ']', + # 'test_pose_targets': '[' + # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', ########################## # Test 2 (pose): ########################## @@ -69,8 +76,10 @@ def generate_launch_description(): # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home # ']', 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json - 'target_stiffness': [1500.0, 150.0], - 'target_damping': [100.0, 15.0], + 'target_pose_stiffness': [1000.0, 150.0], + 'target_pose_damping': [200.0, 54.7723], + 'target_joint_stiffness': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0], + 'target_joint_damping': [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], 'publish_duration': 3.0, 'stop_duration': 2.0 } diff --git a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py index 83b37728c..286a7ef1f 100755 --- a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py +++ b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py @@ -27,6 +27,7 @@ from rclpy.node import Node from aic_control_interfaces.msg import ( MotionUpdate, + JointMotionUpdate, ControllerState, TrajectoryGenerationMode, TargetMode, @@ -35,6 +36,8 @@ ChangeTargetMode, ) from geometry_msgs.msg import Pose, Point, Quaternion, Wrench, Vector3, Twist, WrenchStamped +from trajectory_msgs.msg import JointTrajectoryPoint +from sensor_msgs.msg import JointState class TestRobotControlBridgeNode(Node): @@ -51,20 +54,35 @@ def __init__(self): "test_pose_targets", "[]" ).value + self.test_joint_targets_str = self.declare_parameter( + "test_joint_targets", "[]" + ).value + + self.test_mode = self.declare_parameter( + "test_mode", "pose" + ).value self.log_filepath = self.declare_parameter( "log_filepath", "" ).value stiffness_param = self.declare_parameter( - "target_stiffness", [10.0, 10.0] + "target_pose_stiffness", [10.0, 10.0] ).value - self.target_stiffness = [stiffness_param[0]] * 3 + [stiffness_param[1]] * 3 + self.target_pose_stiffness = [stiffness_param[0]] * 3 + [stiffness_param[1]] * 3 damping_param = self.declare_parameter( - "target_damping", [5.0, 5.0] + "target_pose_damping", [5.0, 5.0] + ).value + self.target_pose_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 + + self.target_joint_stiffness = self.declare_parameter( + "target_joint_stiffness", [3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0] + ).value + + self.target_joint_damping = self.declare_parameter( + "target_joint_damping", [50.0, 50.0, 50.0, 50.0, 50.0, 50.0] ).value - self.target_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 self.publish_duration = self.declare_parameter( "publish_duration", 5.0 @@ -84,8 +102,21 @@ def __init__(self): else: self.test_pose_targets = parsed_targets + parsed_joint_targets = json.loads(self.test_joint_targets_str) + if parsed_joint_targets and not isinstance(parsed_joint_targets[0], list): + # Reshape 1D array into 2D array of joint targets (6 elements each) + self.test_joint_targets = [ + parsed_joint_targets[i : i + 6] + for i in range(0, len(parsed_joint_targets), 6) + ] + else: + self.test_joint_targets = parsed_joint_targets + self.tcp_error = None self.latest_wrench = None + self.current_joint_state = None + self.reference_joint_state = None + self.joint_error = None self.wrench_subscriber = self.create_subscription( WrenchStamped, @@ -98,11 +129,22 @@ def __init__(self): MotionUpdate, f"/{self.controller_namespace}/pose_commands", 10 ) - while self.motion_update_publisher.get_subscription_count() == 0: - self.get_logger().info( - f"Waiting for subscriber to '{self.controller_namespace}/pose_commands'..." - ) - time.sleep(1.0) + self.joint_motion_update_publisher = self.create_publisher( + JointMotionUpdate, f"/{self.controller_namespace}/joint_commands", 10 + ) + + if self.test_mode == "pose": + while self.motion_update_publisher.get_subscription_count() == 0: + self.get_logger().info( + f"Waiting for subscriber to '{self.controller_namespace}/pose_commands'..." + ) + time.sleep(1.0) + elif self.test_mode == "joint": + while self.joint_motion_update_publisher.get_subscription_count() == 0: + self.get_logger().info( + f"Waiting for subscriber to '{self.controller_namespace}/joint_commands'..." + ) + time.sleep(1.0) self.state_subscriber = self.create_subscription( ControllerState, @@ -111,6 +153,13 @@ def __init__(self): 10 ) + self.joint_state_subscriber = self.create_subscription( + JointState, + "/joint_states", + self.joint_state_callback, + 10 + ) + self.client = self.create_client( ChangeTargetMode, f"/{self.controller_namespace}/change_target_mode" ) @@ -122,8 +171,16 @@ def __init__(self): ) time.sleep(1.0) + def joint_state_callback(self, msg: JointState): + self.current_joint_state = msg.position + if self.reference_joint_state is not None and len(self.reference_joint_state) > 0: + self.joint_error = [abs(c - r) for c, r in zip(self.current_joint_state, self.reference_joint_state)] + def state_callback(self, msg: ControllerState): self.tcp_error = list(msg.tcp_error) + self.reference_joint_state = msg.reference_joint_state.positions + if self.current_joint_state is not None and self.reference_joint_state is not None and len(self.reference_joint_state) > 0: + self.joint_error = [abs(c - r) for c, r in zip(self.current_joint_state, self.reference_joint_state)] def wrench_callback(self, msg: WrenchStamped): self.latest_wrench = [ @@ -143,7 +200,6 @@ def generate_motion_update( mode=TrajectoryGenerationMode.MODE_POSITION, twist=None, ): - msg = MotionUpdate() msg.header.stamp = self.get_clock().now().to_msg() msg.header.frame_id = frame_id @@ -157,8 +213,8 @@ def generate_motion_update( linear=Vector3(x=twist[0], y=twist[1], z=twist[2]), angular=Vector3(x=twist[3], y=twist[4], z=twist[5]), ) - msg.target_stiffness = np.diag(self.target_stiffness).flatten() - msg.target_damping = np.diag(self.target_damping).flatten() + msg.target_stiffness = np.diag(self.target_pose_stiffness).flatten() + msg.target_damping = np.diag(self.target_pose_damping).flatten() msg.feedforward_wrench_at_tip = Wrench( force=Vector3(x=0.0, y=0.0, z=0.0), torque=Vector3(x=0.0, y=0.0, z=0.0), @@ -168,6 +224,25 @@ def generate_motion_update( return msg + def generate_joint_motion_update( + self, + positions, + mode=TrajectoryGenerationMode.MODE_POSITION, + velocities=None, + ): + msg = JointMotionUpdate() + if mode == TrajectoryGenerationMode.MODE_POSITION: + msg.target_state.positions = positions + elif mode == TrajectoryGenerationMode.MODE_VELOCITY: + msg.target_state.velocities = velocities + + msg.target_stiffness = self.target_joint_stiffness + msg.target_damping = self.target_joint_damping + msg.target_feedforward_torque = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + msg.trajectory_generation_mode.mode = mode + + return msg + def send_cartesian_pose_target(self, pos, quat, frame_id): self.motion_update_publisher.publish( @@ -176,6 +251,14 @@ def send_cartesian_pose_target(self, pos, quat, frame_id): ) ) + def send_joint_target(self, positions): + + self.joint_motion_update_publisher.publish( + self.generate_joint_motion_update( + positions, TrajectoryGenerationMode.MODE_POSITION + ) + ) + def send_change_target_mode_req(self, mode): req = ChangeTargetMode.Request() @@ -204,40 +287,69 @@ def main(args=None): node = TestRobotControlBridgeNode() try: - # Send service request to switch to Cartesian target mode - node.send_change_target_mode_req(TargetMode.MODE_CARTESIAN) - output_log = { - "target_stiffness": node.target_stiffness, - "target_damping": node.target_damping, + "target_pose_stiffness": node.target_pose_stiffness, + "target_pose_damping": node.target_pose_damping, + "target_joint_stiffness": node.target_joint_stiffness, + "target_joint_damping": node.target_joint_damping, "results": {} } - for pose in node.test_pose_targets: - # pose is expected to be [x, y, z, qx, qy, qz, qw] - pos = pose[0:3] - quat = pose[3:7] - - node.get_logger().info(f"Testing pose target: {pose}") - - node.get_logger().info(f"Publishing motion update for {node.publish_duration} seconds.") - start_time = time.time() - while time.time() - start_time < node.publish_duration and rclpy.ok(): - node.send_cartesian_pose_target(pos, quat, "base_link") - rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz - - node.get_logger().info(f"Stopping motion updates for {node.stop_duration} seconds.") - start_time = time.time() - while time.time() - start_time < node.stop_duration and rclpy.ok(): - rclpy.spin_once(node, timeout_sec=0.1) - - if node.tcp_error is not None: - node.get_logger().info(f"Recording tcp_error: {node.tcp_error}") - recorded_data = {"tcp_error": node.tcp_error} - if node.latest_wrench is not None: - node.get_logger().info(f"Recording wrench: {node.latest_wrench}") - recorded_data["wrench"] = node.latest_wrench - output_log["results"][str(pose)] = recorded_data + if node.test_mode == "pose" and node.test_pose_targets: + # Send service request to switch to Cartesian target mode + node.send_change_target_mode_req(TargetMode.MODE_CARTESIAN) + + for pose in node.test_pose_targets: + # pose is expected to be [x, y, z, qx, qy, qz, qw] + pos = pose[0:3] + quat = pose[3:7] + + node.get_logger().info(f"Testing pose target: {pose}") + + node.get_logger().info(f"Publishing motion update for {node.publish_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.publish_duration and rclpy.ok(): + node.send_cartesian_pose_target(pos, quat, "base_link") + rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz + + node.get_logger().info(f"Stopping motion updates for {node.stop_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.stop_duration and rclpy.ok(): + rclpy.spin_once(node, timeout_sec=0.1) + + if node.tcp_error is not None: + node.get_logger().info(f"Recording tcp_error: {node.tcp_error}") + recorded_data = {"tcp_error": node.tcp_error} + if node.latest_wrench is not None: + node.get_logger().info(f"Recording wrench: {node.latest_wrench}") + recorded_data["wrench"] = node.latest_wrench + output_log["results"][str(pose)] = recorded_data + + if node.test_mode == "joint" and node.test_joint_targets: + # Send service request to switch to Joint target mode + node.send_change_target_mode_req(TargetMode.MODE_JOINT) + + for joint_target in node.test_joint_targets: + node.get_logger().info(f"Testing joint target: {joint_target}") + + node.get_logger().info(f"Publishing joint motion update for {node.publish_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.publish_duration and rclpy.ok(): + node.send_joint_target(joint_target) + rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz + + node.get_logger().info(f"Stopping joint motion updates for {node.stop_duration} seconds.") + start_time = time.time() + while time.time() - start_time < node.stop_duration and rclpy.ok(): + rclpy.spin_once(node, timeout_sec=0.1) + + if node.joint_error is not None: + node.get_logger().info(f"Recording joint_error: {node.joint_error}") + recorded_data = {"joint_error": node.joint_error} + if node.latest_wrench is not None: + node.get_logger().info(f"Recording wrench: {node.latest_wrench}") + recorded_data["wrench"] = node.latest_wrench + output_log["results"][str(joint_target)] = recorded_data if output_log["results"]: if node.log_filepath: From b292ab04eed67c42ba5d5bce28a2be9f1c25cc34 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Fri, 24 Jul 2026 15:03:50 +0800 Subject: [PATCH 07/24] change default values for stiffness and damping parameters --- .../launch/test_joint_targets.launch.py | 9 +- .../launch/test_pose_targets.launch.py | 85 ++++++++++--------- .../scripts/test_robot_control_bridge.py | 4 +- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index 552c47746..de1bea1f5 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -20,16 +20,17 @@ def generate_launch_description(): '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' ']', ########################## - # Position 1: + # Multiple positions ########################## # 'test_joint_targets': '[' - # '0.0, -0.785, 0.0, -2.356, 0.0, 1.571 ' + # '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' + # '-1.57, -1.57, -1.57, -1.57, 1.57, 0.0 ' # ']', 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json 'target_pose_stiffness': [1000.0, 150.0], 'target_pose_damping': [200.0, 54.7723], - 'target_joint_stiffness': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0], - 'target_joint_damping': [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], + 'target_joint_stiffness': [25.0, 25.0, 25.0, 5.0, 5.0, 5.0], + 'target_joint_damping': [5.0, 5.0, 5.0, 5.0, 5.0, 5.0], 'publish_duration': 3.0, 'stop_duration': 2.0 } diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index 4cef82b02..13b9576cd 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -18,14 +18,19 @@ def generate_launch_description(): ########################## # Home position ########################## - 'test_pose_targets': '[' - '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - ']', + # 'test_pose_targets': '[' + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', ########################## # Test contact ########################## + # Pre-contact # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.16, 0.7071068, -0.7071068, 0.0, 0.0 ' + # '-0.1, -0.5, 0.175, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + # Contact! + # 'test_pose_targets': '[' + # '-0.1, -0.5, 0.155, 0.7071068, -0.7071068, 0.0, 0.0 ' # ']', ########################## # Test 1 (position): @@ -42,45 +47,47 @@ def generate_launch_description(): ########################## # Test 2 (pose): ########################## - # 'test_pose_targets': '[' - # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #A: +45 x - # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #A: -45 x - # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #A: +45 y - # '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #A: -45 y - # #### - # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #B: +45 x - # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #B: -45 x - # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #B: +45 y - # '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #B: -45 y - # #### - # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #C: +45 x - # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #C: -45 x - # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #C: +45 y - # '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #C: -45 y - # #### - # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #D: +45 x - # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #D: -45 x - # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #D: +45 y - # '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #D: -45 y - # #### - # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #E: +45 x - # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #E: -45 x - # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #E: +45 y - # '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #E: -45 y - # #### - # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, ' #F: +45 x - # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, ' #F: -45 x - # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, ' #F: +45 y - # '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #F: -45 y - # #### - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home - # ']', + 'test_pose_targets': '[' + '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #A: +45 x + '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #A: -45 x + '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #A: +45 y + '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #A: -45 y + #### + '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #B: +45 x + '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #B: -45 x + '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #B: +45 y + '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #B: -45 y + #### + '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #C: +45 x + '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #C: -45 x + '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #C: +45 y + '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #C: -45 y + #### + '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #D: +45 x + '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #D: -45 x + '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #D: +45 y + '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #D: -45 y + #### + '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #E: +45 x + '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #E: -45 x + '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #E: +45 y + '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #E: -45 y + #### + '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, ' #F: +45 x + '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, ' #F: -45 x + '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, ' #F: +45 y + '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #F: -45 y + #### + '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home + ']', 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json 'target_pose_stiffness': [1000.0, 150.0], - 'target_pose_damping': [200.0, 54.7723], + # 'target_pose_damping': [200.0, 54.7723], # Crtically damped + # 'target_pose_damping': [1800.0, 1265.787853], # Overdamped + 'target_pose_damping': [600.0, 150.0], # Slightly Overdamped 'target_joint_stiffness': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0], 'target_joint_damping': [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], - 'publish_duration': 3.0, + 'publish_duration': 5.0, 'stop_duration': 2.0 } ] diff --git a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py index 286a7ef1f..6d6a8ca69 100755 --- a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py +++ b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py @@ -77,11 +77,11 @@ def __init__(self): self.target_pose_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 self.target_joint_stiffness = self.declare_parameter( - "target_joint_stiffness", [3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0] + "target_joint_stiffness", [50.0, 50.0, 50.0, 10.0, 10.0, 10.0] ).value self.target_joint_damping = self.declare_parameter( - "target_joint_damping", [50.0, 50.0, 50.0, 50.0, 50.0, 50.0] + "target_joint_damping", [25.0, 25.0, 25.0, 5.0, 5.0, 5.0] ).value self.publish_duration = self.declare_parameter( From 3e7aba7b919e081c2992eec7f22ee7b853d771e8 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Fri, 24 Jul 2026 15:06:39 +0800 Subject: [PATCH 08/24] linting --- .../launch/test_joint_targets.launch.py | 71 +++---- .../launch/test_pose_targets.launch.py | 190 +++++++++--------- .../scripts/test_robot_control_bridge.py | 96 +++++---- 3 files changed, 193 insertions(+), 164 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index de1bea1f5..60c771bd6 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -2,38 +2,41 @@ from launch import LaunchDescription from launch_ros.actions import Node + def generate_launch_description(): - return LaunchDescription([ - Node( - package='aic_flowstate_ros_bridge', - executable='test_robot_control_bridge.py', - name='test_robot_control_bridge_node', - output='screen', - parameters=[ - { - 'controller_namespace': 'aic_controller', - 'test_mode': 'joint', - ########################## - # Home position: - ########################## - 'test_joint_targets': '[' - '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' - ']', - ########################## - # Multiple positions - ########################## - # 'test_joint_targets': '[' - # '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' - # '-1.57, -1.57, -1.57, -1.57, 1.57, 0.0 ' - # ']', - 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json - 'target_pose_stiffness': [1000.0, 150.0], - 'target_pose_damping': [200.0, 54.7723], - 'target_joint_stiffness': [25.0, 25.0, 25.0, 5.0, 5.0, 5.0], - 'target_joint_damping': [5.0, 5.0, 5.0, 5.0, 5.0, 5.0], - 'publish_duration': 3.0, - 'stop_duration': 2.0 - } - ] - ) - ]) + return LaunchDescription( + [ + Node( + package="aic_flowstate_ros_bridge", + executable="test_robot_control_bridge.py", + name="test_robot_control_bridge_node", + output="screen", + parameters=[ + { + "controller_namespace": "aic_controller", + "test_mode": "joint", + ########################## + # Home position: + ########################## + "test_joint_targets": "[" + "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" + "]", + ########################## + # Multiple positions + ########################## + # 'test_joint_targets': '[' + # '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' + # '-1.57, -1.57, -1.57, -1.57, 1.57, 0.0 ' + # ']', + "log_filepath": "", # Empty string defaults to tcp_accuracy_.json + "target_pose_stiffness": [1000.0, 150.0], + "target_pose_damping": [200.0, 54.7723], + "target_joint_stiffness": [25.0, 25.0, 25.0, 5.0, 5.0, 5.0], + "target_joint_damping": [5.0, 5.0, 5.0, 5.0, 5.0, 5.0], + "publish_duration": 3.0, + "stop_duration": 2.0, + } + ], + ) + ] + ) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index 13b9576cd..40bf9f021 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -2,94 +2,104 @@ from launch import LaunchDescription from launch_ros.actions import Node + def generate_launch_description(): - return LaunchDescription([ - Node( - package='aic_flowstate_ros_bridge', - executable='test_robot_control_bridge.py', - name='test_robot_control_bridge_node', - output='screen', - parameters=[ - { - 'controller_namespace': 'aic_controller', - 'test_mode': 'pose', - # Example test_pose_targets format: JSON string of a flattened list of poses (or list of lists). - # The list is automatically chunked into 7 elements per pose: [x, y, z, qx, qy, qz, qw] - ########################## - # Home position - ########################## - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test contact - ########################## - # Pre-contact - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.175, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - # Contact! - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.155, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test 1 (position): - ########################## - # 'test_pose_targets': '[' - # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test 2 (pose): - ########################## - 'test_pose_targets': '[' - '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #A: +45 x - '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #A: -45 x - '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #A: +45 y - '-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #A: -45 y - #### - '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #B: +45 x - '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #B: -45 x - '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #B: +45 y - '-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #B: -45 y - #### - '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #C: +45 x - '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #C: -45 x - '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #C: +45 y - '-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #C: -45 y - #### - '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #D: +45 x - '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #D: -45 x - '0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #D: +45 y - '0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #D: -45 y - #### - '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981,' #E: +45 x - '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981,' #E: -45 x - '0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981,' #E: +45 y - '0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #E: -45 y - #### - '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, ' #F: +45 x - '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, ' #F: -45 x - '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, ' #F: +45 y - '-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981,' #F: -45 y - #### - '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' # Home - ']', - 'log_filepath': '', # Empty string defaults to tcp_accuracy_.json - 'target_pose_stiffness': [1000.0, 150.0], - # 'target_pose_damping': [200.0, 54.7723], # Crtically damped - # 'target_pose_damping': [1800.0, 1265.787853], # Overdamped - 'target_pose_damping': [600.0, 150.0], # Slightly Overdamped - 'target_joint_stiffness': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0], - 'target_joint_damping': [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], - 'publish_duration': 5.0, - 'stop_duration': 2.0 - } - ] - ) - ]) + return LaunchDescription( + [ + Node( + package="aic_flowstate_ros_bridge", + executable="test_robot_control_bridge.py", + name="test_robot_control_bridge_node", + output="screen", + parameters=[ + { + "controller_namespace": "aic_controller", + "test_mode": "pose", + # Example test_pose_targets format: JSON string of a flattened list of poses (or list of lists). + # The list is automatically chunked into 7 elements per pose: [x, y, z, qx, qy, qz, qw] + ########################## + # Home position + ########################## + # 'test_pose_targets': '[' + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + ########################## + # Test contact + ########################## + # Pre-contact + # 'test_pose_targets': '[' + # '-0.1, -0.5, 0.175, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + # Contact! + # 'test_pose_targets': '[' + # '-0.1, -0.5, 0.155, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + ########################## + # Test 1 (position): + ########################## + # 'test_pose_targets': '[' + # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' + # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + # ']', + ########################## + # Test 2 (pose): + ########################## + "test_pose_targets": "[" + "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # A: +45 x + "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # A: -45 x + "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # A: +45 y + "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # A: -45 y + #### + "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # B: +45 x + "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # B: -45 x + "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # B: +45 y + "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # B: -45 y + #### + "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # C: +45 x + "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # C: -45 x + "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # C: +45 y + "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # C: -45 y + #### + "0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # D: +45 x + "0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # D: -45 x + "0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # D: +45 y + "0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # D: -45 y + #### + "0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # E: +45 x + "0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # E: -45 x + "0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # E: +45 y + "0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # E: -45 y + #### + "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, " # F: +45 x + "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, " # F: -45 x + "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, " # F: +45 y + "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # F: -45 y + #### + "-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 " # Home + "]", + "log_filepath": "", # Empty string defaults to tcp_accuracy_.json + "target_pose_stiffness": [1000.0, 150.0], + # 'target_pose_damping': [200.0, 54.7723], # Crtically damped + # 'target_pose_damping': [1800.0, 1265.787853], # Overdamped + "target_pose_damping": [600.0, 150.0], # Slightly Overdamped + "target_joint_stiffness": [ + 100.0, + 100.0, + 100.0, + 100.0, + 100.0, + 100.0, + ], + "target_joint_damping": [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], + "publish_duration": 5.0, + "stop_duration": 2.0, + } + ], + ) + ] + ) diff --git a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py index 6d6a8ca69..a0849d32c 100755 --- a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py +++ b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py @@ -35,7 +35,15 @@ from aic_control_interfaces.srv import ( ChangeTargetMode, ) -from geometry_msgs.msg import Pose, Point, Quaternion, Wrench, Vector3, Twist, WrenchStamped +from geometry_msgs.msg import ( + Pose, + Point, + Quaternion, + Wrench, + Vector3, + Twist, + WrenchStamped, +) from trajectory_msgs.msg import JointTrajectoryPoint from sensor_msgs.msg import JointState @@ -58,22 +66,16 @@ def __init__(self): "test_joint_targets", "[]" ).value - self.test_mode = self.declare_parameter( - "test_mode", "pose" - ).value + self.test_mode = self.declare_parameter("test_mode", "pose").value - self.log_filepath = self.declare_parameter( - "log_filepath", "" - ).value + self.log_filepath = self.declare_parameter("log_filepath", "").value stiffness_param = self.declare_parameter( "target_pose_stiffness", [10.0, 10.0] ).value self.target_pose_stiffness = [stiffness_param[0]] * 3 + [stiffness_param[1]] * 3 - damping_param = self.declare_parameter( - "target_pose_damping", [5.0, 5.0] - ).value + damping_param = self.declare_parameter("target_pose_damping", [5.0, 5.0]).value self.target_pose_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 self.target_joint_stiffness = self.declare_parameter( @@ -84,20 +86,15 @@ def __init__(self): "target_joint_damping", [25.0, 25.0, 25.0, 5.0, 5.0, 5.0] ).value - self.publish_duration = self.declare_parameter( - "publish_duration", 5.0 - ).value + self.publish_duration = self.declare_parameter("publish_duration", 5.0).value - self.stop_duration = self.declare_parameter( - "stop_duration", 5.0 - ).value + self.stop_duration = self.declare_parameter("stop_duration", 5.0).value parsed_targets = json.loads(self.test_pose_targets_str) if parsed_targets and not isinstance(parsed_targets[0], list): # Reshape 1D array into 2D array of poses (7 elements each) self.test_pose_targets = [ - parsed_targets[i : i + 7] - for i in range(0, len(parsed_targets), 7) + parsed_targets[i : i + 7] for i in range(0, len(parsed_targets), 7) ] else: self.test_pose_targets = parsed_targets @@ -119,10 +116,7 @@ def __init__(self): self.joint_error = None self.wrench_subscriber = self.create_subscription( - WrenchStamped, - "/fts_broadcaster/wrench", - self.wrench_callback, - 10 + WrenchStamped, "/fts_broadcaster/wrench", self.wrench_callback, 10 ) self.motion_update_publisher = self.create_publisher( @@ -150,14 +144,11 @@ def __init__(self): ControllerState, f"/{self.controller_namespace}/controller_state", self.state_callback, - 10 + 10, ) self.joint_state_subscriber = self.create_subscription( - JointState, - "/joint_states", - self.joint_state_callback, - 10 + JointState, "/joint_states", self.joint_state_callback, 10 ) self.client = self.create_client( @@ -173,14 +164,27 @@ def __init__(self): def joint_state_callback(self, msg: JointState): self.current_joint_state = msg.position - if self.reference_joint_state is not None and len(self.reference_joint_state) > 0: - self.joint_error = [abs(c - r) for c, r in zip(self.current_joint_state, self.reference_joint_state)] + if ( + self.reference_joint_state is not None + and len(self.reference_joint_state) > 0 + ): + self.joint_error = [ + abs(c - r) + for c, r in zip(self.current_joint_state, self.reference_joint_state) + ] def state_callback(self, msg: ControllerState): self.tcp_error = list(msg.tcp_error) self.reference_joint_state = msg.reference_joint_state.positions - if self.current_joint_state is not None and self.reference_joint_state is not None and len(self.reference_joint_state) > 0: - self.joint_error = [abs(c - r) for c, r in zip(self.current_joint_state, self.reference_joint_state)] + if ( + self.current_joint_state is not None + and self.reference_joint_state is not None + and len(self.reference_joint_state) > 0 + ): + self.joint_error = [ + abs(c - r) + for c, r in zip(self.current_joint_state, self.reference_joint_state) + ] def wrench_callback(self, msg: WrenchStamped): self.latest_wrench = [ @@ -292,7 +296,7 @@ def main(args=None): "target_pose_damping": node.target_pose_damping, "target_joint_stiffness": node.target_joint_stiffness, "target_joint_damping": node.target_joint_damping, - "results": {} + "results": {}, } if node.test_mode == "pose" and node.test_pose_targets: @@ -306,13 +310,17 @@ def main(args=None): node.get_logger().info(f"Testing pose target: {pose}") - node.get_logger().info(f"Publishing motion update for {node.publish_duration} seconds.") + node.get_logger().info( + f"Publishing motion update for {node.publish_duration} seconds." + ) start_time = time.time() while time.time() - start_time < node.publish_duration and rclpy.ok(): node.send_cartesian_pose_target(pos, quat, "base_link") - rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz + rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz - node.get_logger().info(f"Stopping motion updates for {node.stop_duration} seconds.") + node.get_logger().info( + f"Stopping motion updates for {node.stop_duration} seconds." + ) start_time = time.time() while time.time() - start_time < node.stop_duration and rclpy.ok(): rclpy.spin_once(node, timeout_sec=0.1) @@ -321,7 +329,9 @@ def main(args=None): node.get_logger().info(f"Recording tcp_error: {node.tcp_error}") recorded_data = {"tcp_error": node.tcp_error} if node.latest_wrench is not None: - node.get_logger().info(f"Recording wrench: {node.latest_wrench}") + node.get_logger().info( + f"Recording wrench: {node.latest_wrench}" + ) recorded_data["wrench"] = node.latest_wrench output_log["results"][str(pose)] = recorded_data @@ -332,13 +342,17 @@ def main(args=None): for joint_target in node.test_joint_targets: node.get_logger().info(f"Testing joint target: {joint_target}") - node.get_logger().info(f"Publishing joint motion update for {node.publish_duration} seconds.") + node.get_logger().info( + f"Publishing joint motion update for {node.publish_duration} seconds." + ) start_time = time.time() while time.time() - start_time < node.publish_duration and rclpy.ok(): node.send_joint_target(joint_target) - rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz + rclpy.spin_once(node, timeout_sec=0.04) # 25 Hz - node.get_logger().info(f"Stopping joint motion updates for {node.stop_duration} seconds.") + node.get_logger().info( + f"Stopping joint motion updates for {node.stop_duration} seconds." + ) start_time = time.time() while time.time() - start_time < node.stop_duration and rclpy.ok(): rclpy.spin_once(node, timeout_sec=0.1) @@ -347,7 +361,9 @@ def main(args=None): node.get_logger().info(f"Recording joint_error: {node.joint_error}") recorded_data = {"joint_error": node.joint_error} if node.latest_wrench is not None: - node.get_logger().info(f"Recording wrench: {node.latest_wrench}") + node.get_logger().info( + f"Recording wrench: {node.latest_wrench}" + ) recorded_data["wrench"] = node.latest_wrench output_log["results"][str(joint_target)] = recorded_data From 1c961ed14a75cc6ab1152806e624cdd2387e40b5 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Mon, 27 Jul 2026 22:25:31 +0800 Subject: [PATCH 09/24] 1. Update Interpolation method to use REFLEXXES instead of LINEAR_INTERPOLATION, which should respect kinematic constraints. 2. Also Update the max_distance to a much smaller value (0.1 radians) to scale down velocity and acceleration commands for setpoints that exceed this value --- .../config/default_joint_task_settings.pbtxt | 11 ++++++----- .../config/default_task_settings.pbtxt | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt index 0d8591d4b..68bd1167c 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt @@ -6,12 +6,12 @@ damping_smoothing_constant: 0.1 # These limits cannot exceed the application limits. joint_limits_update: { - min_position: { values: [-6.22, -4.059, -2.77, -6.22, -6.22, 1.571] } - max_position: { values: [6.22, 0.95, 2.77, 6.22, 6.22, 4.712] } + min_position: { values: [-6.22, -4.059, -2.77, -6.22, -6.22, -3.0] } + max_position: { values: [6.22, 0.95, 2.77, 6.22, 6.22, 3.0] } # For safety/testing, reducing velocity limits is usually the most intuitive # and all that matters for conservative motion. Reducting acceleration and # jerk limits can have counter-intuitive behavior. - max_velocity: { values: [0.746, 0.746, 0.746, 0.746, 0.746, 0.746] } + max_velocity: { values: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3] } max_acceleration: { values: [5, 5, 5, 5, 5, 5] } max_jerk: { values: [8001, 8001, 8001, 8001, 8001, 8001] } max_effort: { values: [100.0, 100.0, 100.0, 28.0, 28.0, 28.0] } @@ -21,7 +21,8 @@ joint_limits_update: { # towards zero if the motion would push towards the limit. limits_soft_margin_radians: 0.02 -interpolation_mode: LINEAR_INTERPOLATION +# Using reflexxes interpolation constraints commands to specified kinematic limits +interpolation_mode: REFLEXXES # Stiffness and damping cannot exceed the application limits. stiffness: { @@ -42,6 +43,6 @@ feedforward_torque_interpolator_settings: { # the current joint position. An adjustment of the reference position starts # at max_distance*activation_ratio. reference_joint_limit_settings: { - max_distance: 0.75 + max_distance: 0.1 activation_ratio: 0.75 } diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index ef5016be6..6bb290be1 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -75,7 +75,8 @@ nullspace_target_configuration { joints: [0.0, 0.0, 0.0, 0.0, 1.57, 0.0] } activation_percentage: -1 -interpolation_mode: LINEAR_INTERPOLATION +# Using reflexxes interpolation constraints commands to specified kinematic limits +interpolation_mode: REFLEXXES # Parameters for limiting the distance between reference pose and sensed pose. # From fdf2337f2653b1d65b3807e9a03e7a2202050559 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Mon, 27 Jul 2026 22:31:45 +0800 Subject: [PATCH 10/24] update testing script --- .../launch/test_joint_targets.launch.py | 23 +++++++++---------- .../launch/test_pose_targets.launch.py | 9 -------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index 60c771bd6..1e21e213d 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -18,21 +18,20 @@ def generate_launch_description(): ########################## # Home position: ########################## - "test_joint_targets": "[" - "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" - "]", + # "test_joint_targets": "[" + # "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" + # "]", ########################## - # Multiple positions + # Test 1: ########################## - # 'test_joint_targets': '[' - # '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' - # '-1.57, -1.57, -1.57, -1.57, 1.57, 0.0 ' - # ']', + 'test_joint_targets': '[' + '-1.27, -1.8, -1.47, -1.57, 1.57, -1.57,' + # Home + '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' + ']', "log_filepath": "", # Empty string defaults to tcp_accuracy_.json - "target_pose_stiffness": [1000.0, 150.0], - "target_pose_damping": [200.0, 54.7723], - "target_joint_stiffness": [25.0, 25.0, 25.0, 5.0, 5.0, 5.0], - "target_joint_damping": [5.0, 5.0, 5.0, 5.0, 5.0, 5.0], + "target_joint_stiffness": [100.0, 100.0, 100.0, 25.0, 25.0, 25.0], + "target_joint_damping": [10.0, 10.0, 10.0, 5.0, 5.0, 5.0], "publish_duration": 3.0, "stop_duration": 2.0, } diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index 40bf9f021..45f0949cf 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -87,15 +87,6 @@ def generate_launch_description(): # 'target_pose_damping': [200.0, 54.7723], # Crtically damped # 'target_pose_damping': [1800.0, 1265.787853], # Overdamped "target_pose_damping": [600.0, 150.0], # Slightly Overdamped - "target_joint_stiffness": [ - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - 100.0, - ], - "target_joint_damping": [10.0, 10.0, 10.0, 10.0, 10.0, 10.0], "publish_duration": 5.0, "stop_duration": 2.0, } From 1c10d9136c60c3eda3200f2be2c86e7275c10097 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Mon, 27 Jul 2026 22:56:24 +0800 Subject: [PATCH 11/24] linting --- .../launch/test_joint_targets.launch.py | 16 ++++-- .../src/aic_flowstate_ros_bridge_main.cpp | 5 +- .../src/robot_control_bridge.cpp | 52 ++++++++++--------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index 1e21e213d..40a1e8a20 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -24,13 +24,19 @@ def generate_launch_description(): ########################## # Test 1: ########################## - 'test_joint_targets': '[' - '-1.27, -1.8, -1.47, -1.57, 1.57, -1.57,' + "test_joint_targets": "[" + "-1.27, -1.8, -1.47, -1.57, 1.57, -1.57," # Home - '-1.57, -1.57, -1.57, -1.57, 1.57, -1.57' - ']', + "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json - "target_joint_stiffness": [100.0, 100.0, 100.0, 25.0, 25.0, 25.0], + "target_joint_stiffness": [ + 100.0, + 100.0, + 100.0, + 25.0, + 25.0, + 25.0, + ], "target_joint_damping": [10.0, 10.0, 10.0, 5.0, 5.0, 5.0], "publish_duration": 3.0, "stop_duration": 2.0, diff --git a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp index c5fa5b49a..e80cc3c3b 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/aic_flowstate_ros_bridge_main.cpp @@ -141,9 +141,10 @@ int main(int argc, char* argv[]) { robot_control_bridge_config.time_to_target_seconds()); params.emplace_back("control_mode", robot_control_bridge_config.control_mode()); - + const auto& critical_mass_proto = robot_control_bridge_config.critical_mass(); - std::vector critical_mass(critical_mass_proto.begin(), critical_mass_proto.end()); + std::vector critical_mass(critical_mass_proto.begin(), + critical_mass_proto.end()); params.emplace_back("critical_mass", critical_mass); const auto& override_joint_names_proto = s.override_joint_names(); std::vector override_joint_names( diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 4dde55051..1a5d89c6f 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -58,8 +58,7 @@ constexpr const char* kFlowstateZenohRouterParamName = "flowstate_zenoh_router_address"; constexpr const char* kRestartConnectionRetriesParamName = "restart_connection_retries"; -constexpr const char* kTimeToTargetSecondsParamName = - "time_to_target_seconds"; +constexpr const char* kTimeToTargetSecondsParamName = "time_to_target_seconds"; constexpr const char* kControlModeParamName = "control_mode"; constexpr const char* kCriticalMassParamName = "critical_mass"; @@ -88,9 +87,9 @@ void RobotControlBridge::declare_ros_parameters( rclcpp::ParameterValue{0.1}); param_interface->declare_parameter(kControlModeParamName, rclcpp::ParameterValue{"admittance"}); - param_interface->declare_parameter( - kCriticalMassParamName, - rclcpp::ParameterValue{std::vector{5.0, 5.0, 5.0, 5.0, 5.0, 5.0}}); + param_interface->declare_parameter(kCriticalMassParamName, + rclcpp::ParameterValue{std::vector{ + 5.0, 5.0, 5.0, 5.0, 5.0, 5.0}}); } ///============================================================================= @@ -127,9 +126,8 @@ bool RobotControlBridge::initialize( data_->time_to_target_seconds_ = param_interface->get_parameter(kTimeToTargetSecondsParamName) .get_value(); - data_->critical_mass_ = - param_interface->get_parameter(kCriticalMassParamName) - .get_value>(); + data_->critical_mass_ = param_interface->get_parameter(kCriticalMassParamName) + .get_value>(); std::string control_mode_str = param_interface->get_parameter(kControlModeParamName) .get_value(); @@ -716,29 +714,34 @@ bool RobotControlBridge::startControllerAction() { ActionDescriptor agent_bridge_descriptor = data_->ft_sensor_part_name_.has_value() ? ActionDescriptor( - intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, - {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}, + intrinsic::icon::AgentBridgeInfo::kActionTypeName, + kAgentBridgeId, + {{intrinsic::icon::AgentBridgeInfo::kSlotName, + data_->part_name_}, {intrinsic::icon::AgentBridgeInfo::kForceTorqueSlotName, data_->ft_sensor_part_name_.value()}}) .WithFixedParams(data_->agent_bridge_fixed_params_) - : ActionDescriptor( - intrinsic::icon::AgentBridgeInfo::kActionTypeName, kAgentBridgeId, - {{intrinsic::icon::AgentBridgeInfo::kSlotName, data_->part_name_}}) + : ActionDescriptor(intrinsic::icon::AgentBridgeInfo::kActionTypeName, + kAgentBridgeId, + {{intrinsic::icon::AgentBridgeInfo::kSlotName, + data_->part_name_}}) .WithFixedParams(data_->agent_bridge_fixed_params_); ActionDescriptor agent_bridge_joint_descriptor = data_->ft_sensor_part_name_.has_value() - ? ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, - kAgentBridgeJointId, - {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, - data_->part_name_}, - {intrinsic::icon::AgentBridgeJointInfo::kForceTorqueSlotName, - data_->ft_sensor_part_name_.value()}}) + ? ActionDescriptor( + intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, + kAgentBridgeJointId, + {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, + data_->part_name_}, + {intrinsic::icon::AgentBridgeJointInfo::kForceTorqueSlotName, + data_->ft_sensor_part_name_.value()}}) .WithFixedParams(data_->agent_bridge_joint_fixed_params_) - : ActionDescriptor(intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, - kAgentBridgeJointId, - {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, - data_->part_name_}}) + : ActionDescriptor( + intrinsic::icon::AgentBridgeJointInfo::kActionTypeName, + kAgentBridgeJointId, + {{intrinsic::icon::AgentBridgeJointInfo::kSlotName, + data_->part_name_}}) .WithFixedParams(data_->agent_bridge_joint_fixed_params_); // Add the AgentBridge and AgentBridgeJoint actions to the session, then @@ -953,7 +956,8 @@ bool RobotControlBridge::resetMotionUpdate() { return false; } } else { - LOG(ERROR) << "Task settings missing max_stiffness or max_damping parameters."; + LOG(ERROR) + << "Task settings missing max_stiffness or max_damping parameters."; return false; } From 922f873df39298c0024c3db0c811c67886adb5ab Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 28 Jul 2026 22:22:35 +0800 Subject: [PATCH 12/24] update joint/cartesian position/velocity limits --- .../config/default_joint_task_settings.pbtxt | 10 +++++----- .../config/default_task_settings.pbtxt | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt index 68bd1167c..4e835c40a 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt @@ -6,12 +6,12 @@ damping_smoothing_constant: 0.1 # These limits cannot exceed the application limits. joint_limits_update: { - min_position: { values: [-6.22, -4.059, -2.77, -6.22, -6.22, -3.0] } - max_position: { values: [6.22, 0.95, 2.77, 6.22, 6.22, 3.0] } + min_position: { values: [-1.832, -1.919, -2.356, -2.792, -1.658, -1.745] } + max_position: { values: [1.221, 0.0, 0.698, 2.443, 3.141, 4.363] } # For safety/testing, reducing velocity limits is usually the most intuitive # and all that matters for conservative motion. Reducting acceleration and # jerk limits can have counter-intuitive behavior. - max_velocity: { values: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3] } + max_velocity: { values: [0.8, 0.8, 0.8, 0.8, 0.8, 0.8] } max_acceleration: { values: [5, 5, 5, 5, 5, 5] } max_jerk: { values: [8001, 8001, 8001, 8001, 8001, 8001] } max_effort: { values: [100.0, 100.0, 100.0, 28.0, 28.0, 28.0] } @@ -26,10 +26,10 @@ interpolation_mode: REFLEXXES # Stiffness and damping cannot exceed the application limits. stiffness: { - joints: [100., 100., 100., 50., 50., 50.] + joints: [100., 100., 100., 25., 25., 25.] } damping: { - joints: [40.0, 40.0, 40.0, 15.0, 15.0, 15.0] + joints: [10.0, 10.0, 10.0, 5.0, 5.0, 5.0] } # Using ~50% of max_effort -- and this is could be more conservative. diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index 6bb290be1..6e98d71e7 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -18,12 +18,12 @@ cartesian_limits { max_translational_position: 1.0 # y max_translational_position: 1.5 # z - min_translational_velocity: -1.0 - min_translational_velocity: -1.0 - min_translational_velocity: -1.0 - max_translational_velocity: 1.0 - max_translational_velocity: 1.0 - max_translational_velocity: 1.0 + min_translational_velocity: -0.25 + min_translational_velocity: -0.25 + min_translational_velocity: -0.25 + max_translational_velocity: 0.25 + max_translational_velocity: 0.25 + max_translational_velocity: 0.25 min_translational_acceleration: -10 min_translational_acceleration: -10 From 7321af91a3681493ede0cb8f5583e2d5f1a69538 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 29 Jul 2026 22:37:19 +0800 Subject: [PATCH 13/24] add USE_FIXED_CONTROL_PARAMETERS flag to fix the control parameters. It cannot be changed during runtime --- .../aic_flowstate_ros_bridge/CMakeLists.txt | 6 ++ .../config/fixed_task_settings.json | 8 ++ .../aic_flowstate_ros_bridge/package.xml | 1 + .../src/robot_control_bridge.cpp | 100 ++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json diff --git a/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt b/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt index 8293e9b73..4c38e8fd5 100644 --- a/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt +++ b/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt @@ -30,10 +30,15 @@ foreach(pkg ${dep_pkgs}) endforeach() find_package(Eigen3 REQUIRED NO_MODULE) +find_package(nlohmann_json REQUIRED) find_package(Protobuf REQUIRED) find_package(orocos_kdl_vendor REQUIRED) #================================== +option(USE_FIXED_CONTROL_PARAMETERS "Use fixed control parameters" OFF) +if(USE_FIXED_CONTROL_PARAMETERS) + add_compile_definitions(USE_FIXED_CONTROL_PARAMETERS) +endif() intrinsic_sdk_protobuf_generate( NAME agent_bridge @@ -63,6 +68,7 @@ target_link_libraries(robot_control_bridge pluginlib::pluginlib rclcpp::rclcpp tf2_eigen::tf2_eigen + nlohmann_json::nlohmann_json ${aic_control_interfaces_TARGETS} ${std_srvs_TARGETS} ) diff --git a/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json b/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json new file mode 100644 index 000000000..3ce02d7cc --- /dev/null +++ b/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json @@ -0,0 +1,8 @@ +{ + "control_mode": "admittance", + "target_pose_stiffness": [1000.0, 1000.0, 1000.0, 150.0, 150.0, 150.0], + "target_pose_damping": [1562.049935, 1562.049935, 1562.049935, 1096.814453, 1096.814453, 1096.814453], + "target_mass": [10.0, 10.0, 10.0, 5.0, 5.0, 5.0], + "target_joint_stiffness": [50.0, 50.0, 50.0, 10.0, 10.0, 10.0], + "target_joint_damping": [25.0, 25.0, 25.0, 5.0, 5.0, 5.0] +} diff --git a/flowstate/aic_flowstate_ros_bridge/package.xml b/flowstate/aic_flowstate_ros_bridge/package.xml index d0e9780fa..c64d6472b 100644 --- a/flowstate/aic_flowstate_ros_bridge/package.xml +++ b/flowstate/aic_flowstate_ros_bridge/package.xml @@ -18,6 +18,7 @@ pluginlib std_srvs tf2_eigen + nlohmann_json ament_lint_auto ament_lint_common diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 1a5d89c6f..34af9575c 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "absl/flags/flag.h" #include "absl/log/log.h" @@ -204,6 +206,96 @@ bool RobotControlBridge::initialize( throw std::runtime_error("Invalid control_mode parameter."); } +#ifdef USE_FIXED_CONTROL_PARAMETERS + { + std::filesystem::path fixed_json_path = ament_index_cpp::get_package_share_directory("aic_flowstate_ros_bridge") + "/config/fixed_task_settings.json"; + try { + std::ifstream f(fixed_json_path.string()); + if (!f.is_open()) { + throw std::runtime_error("Could not open JSON config file."); + } + nlohmann::json config = nlohmann::json::parse(f); + + auto target_pose_stiffness = config["target_pose_stiffness"].get>(); + auto target_pose_damping = config["target_pose_damping"].get>(); + auto target_mass = config["target_mass"].get>(); + + if (target_pose_stiffness.size() != 6 || target_pose_damping.size() != 6 || target_mass.size() != 6) { + LOG(ERROR) << "Fixed task settings: target_pose_stiffness, target_pose_damping, and target_mass must have exactly 6 elements."; + throw std::runtime_error("Fixed task settings must have exactly 6 elements for pose stiffness, damping, and mass."); + } + + auto* mu = data_->agent_bridge_fixed_params_.mutable_motion_update(); + auto* target_stiffness = mu->mutable_target_stiffness(); + auto* target_damping = mu->mutable_target_damping(); + auto* target_mass_proto = mu->mutable_target_mass(); + target_stiffness->mutable_data()->Resize(36, 0.0); + target_damping->mutable_data()->Resize(36, 0.0); + target_mass_proto->mutable_data()->Resize(36, 0.0); + + if (target_pose_stiffness.size() >= 6) { + target_stiffness->set_data(0, target_pose_stiffness[0]); + target_stiffness->set_data(7, target_pose_stiffness[1]); + target_stiffness->set_data(14, target_pose_stiffness[2]); + target_stiffness->set_data(21, target_pose_stiffness[3]); + target_stiffness->set_data(28, target_pose_stiffness[4]); + target_stiffness->set_data(35, target_pose_stiffness[5]); + } + if (target_pose_damping.size() >= 6) { + target_damping->set_data(0, target_pose_damping[0]); + target_damping->set_data(7, target_pose_damping[1]); + target_damping->set_data(14, target_pose_damping[2]); + target_damping->set_data(21, target_pose_damping[3]); + target_damping->set_data(28, target_pose_damping[4]); + target_damping->set_data(35, target_pose_damping[5]); + } + if (target_mass.size() >= 6) { + target_mass_proto->set_data(0, target_mass[0]); + target_mass_proto->set_data(7, target_mass[1]); + target_mass_proto->set_data(14, target_mass[2]); + target_mass_proto->set_data(21, target_mass[3]); + target_mass_proto->set_data(28, target_mass[4]); + target_mass_proto->set_data(35, target_mass[5]); + } + + auto target_joint_stiffness = config["target_joint_stiffness"].get>(); + auto target_joint_damping = config["target_joint_damping"].get>(); + + if (target_joint_stiffness.size() != 6 || target_joint_damping.size() != 6) { + LOG(ERROR) << "Fixed task settings: target_joint_stiffness and target_joint_damping must have exactly 6 elements."; + throw std::runtime_error("Fixed task settings must have exactly 6 elements for joint stiffness and damping."); + } + + auto* mu_joint = data_->agent_bridge_joint_fixed_params_.mutable_motion_update(); + auto* tjs = mu_joint->mutable_target_stiffness(); + auto* tjd = mu_joint->mutable_target_damping(); + tjs->clear_joints(); + tjd->clear_joints(); + for (double v : target_joint_stiffness) { + tjs->add_joints(v); + } + for (double v : target_joint_damping) { + tjd->add_joints(v); + } + + std::string mode_str = config["control_mode"].get(); + auto* ts = data_->agent_bridge_fixed_params_.mutable_task_settings(); + if (mode_str == "admittance") { + ts->set_control_mode(intrinsic_proto::icon::actions::proto::ControlMode::ADMITTANCE); + } else if (mode_str == "impedance") { + ts->set_control_mode(intrinsic_proto::icon::actions::proto::ControlMode::IMPEDANCE); + } else { + LOG(ERROR) << "Invalid control_mode: " << mode_str; + throw std::runtime_error("Invalid control_mode parameter."); + } + + } catch (const std::exception& e) { + LOG(ERROR) << "Failed to read fixed_task_settings.json: " << e.what(); + throw std::runtime_error("Failed to read fixed_task_settings.json"); + } + } +#endif + // Set default taring cycle of 100 // todo(johntgz) set this as a ros parameter data_->tare_ft_sensor_fixed_params_.set_num_taring_cycles(100); @@ -913,6 +1005,7 @@ bool RobotControlBridge::resetMotionUpdate() { auto* target_state = initial_motion_update->mutable_target_state(); target_state->mutable_velocity()->Resize(6, 0.0); +#ifndef USE_FIXED_CONTROL_PARAMETERS // Use max values from task settings for initial stiffness, damping, and // mass auto* target_stiffness = initial_motion_update->mutable_target_stiffness(); @@ -960,6 +1053,7 @@ bool RobotControlBridge::resetMotionUpdate() { << "Task settings missing max_stiffness or max_damping parameters."; return false; } +#endif auto* fw = initial_motion_update->mutable_feedforward_wrench_at_tip(); fw->set_x(0); @@ -985,6 +1079,7 @@ bool RobotControlBridge::resetMotionUpdate() { ->mutable_velocity() ->Resize(data_->num_joints_, 0.0); +#ifndef USE_FIXED_CONTROL_PARAMETERS auto* target_joint_stiffness = initial_joint_motion_update->mutable_target_stiffness(); auto* target_joint_damping = @@ -1005,6 +1100,7 @@ bool RobotControlBridge::resetMotionUpdate() { target_joint_damping->set_joints(i, damping.joints(i)); } } +#endif return true; } @@ -1152,6 +1248,7 @@ void RobotControlBridge::MotionUpdateCallback( target_state->add_velocity(msg->velocity.angular.y); target_state->add_velocity(msg->velocity.angular.z); +#ifndef USE_FIXED_CONTROL_PARAMETERS // Map stiffness and damping parameters auto* stiffness = proto_msg.mutable_target_stiffness(); auto* damping = proto_msg.mutable_target_damping(); @@ -1161,6 +1258,7 @@ void RobotControlBridge::MotionUpdateCallback( stiffness->add_data(msg->target_stiffness[i]); damping->add_data(msg->target_damping[i]); } +#endif // Map feedforward wrench at tip auto* fw = proto_msg.mutable_feedforward_wrench_at_tip(); @@ -1250,6 +1348,7 @@ void RobotControlBridge::JointMotionUpdateCallback( target_state->add_velocity(vel); } +#ifndef USE_FIXED_CONTROL_PARAMETERS // Map the stiffness and damping parameters auto* stiffness = proto_msg.mutable_target_stiffness(); auto* damping = proto_msg.mutable_target_damping(); @@ -1261,6 +1360,7 @@ void RobotControlBridge::JointMotionUpdateCallback( for (double d : msg->target_damping) { damping->add_joints(d); } +#endif // Map the feedforward torque auto* ff_torque = proto_msg.mutable_target_feedforward_torque(); From d29c3d0e323f733b589f845f874da8a990c08899 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 29 Jul 2026 22:37:42 +0800 Subject: [PATCH 14/24] update joint and cartesian control parameters --- .../config/default_task_settings.pbtxt | 4 ++-- .../launch/test_joint_targets.launch.py | 15 ++++++++++---- .../launch/test_pose_targets.launch.py | 20 +++++++++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index 6e98d71e7..87bf4a8cb 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -4,8 +4,8 @@ # Impedance control parameters need to be tuned for every robot and endeffector. # The values below correspond to a robotiq-2f gripper with Axia80 F/T cell. # with critical damping under the assume mass. -max_stiffness: { x: 800 y: 800 z: 800 rx: 40 ry: 40 rz: 40 } -max_damping: { x: 76 y: 76 z: 76 rx: 10 ry: 10 rz: 10 } +max_stiffness: { x: 1000 y: 1000 z: 1000 rx: 150 ry: 150 rz: 150 } +max_damping: { x: 1562.049935 y: 1562.049935 z: 1562.049935 rx: 1096.814453 ry: 1096.814453 rz: 1096.814453 } mass_for_critical_damping: { x: 10.0 y: 10.0 z: 10.0 rx: 5.0 ry: 5.0 rz: 5.0 } # Limits of a reasonable retangular volume in front the the robot. This should diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index 40a1e8a20..d0ed814d8 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -30,14 +30,21 @@ def generate_launch_description(): "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json "target_joint_stiffness": [ - 100.0, - 100.0, - 100.0, + 50.0, + 50.0, + 50.0, + 10.0, + 10.0, + 10.0, + ], + "target_joint_damping": [ 25.0, 25.0, 25.0, + 5.0, + 5.0, + 5.0, ], - "target_joint_damping": [10.0, 10.0, 10.0, 5.0, 5.0, 5.0], "publish_duration": 3.0, "stop_duration": 2.0, } diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index 45f0949cf..e86d0bfb1 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -83,10 +83,22 @@ def generate_launch_description(): "-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 " # Home "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json - "target_pose_stiffness": [1000.0, 150.0], - # 'target_pose_damping': [200.0, 54.7723], # Crtically damped - # 'target_pose_damping': [1800.0, 1265.787853], # Overdamped - "target_pose_damping": [600.0, 150.0], # Slightly Overdamped + "target_pose_stiffness": [ + 1000.0, + 1000.0, + 1000.0, + 150.0, + 150.0, + 150.0, + ], + "target_pose_damping": [ + 1562.049935, + 1562.049935, + 1562.049935, + 1096.814453, + 1096.814453, + 1096.814453 + ], "publish_duration": 5.0, "stop_duration": 2.0, } From 0f166d6c2d2f2b71cdc3c16859d87bd47ea06be3 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Thu, 30 Jul 2026 17:27:40 +0800 Subject: [PATCH 15/24] update cartesian velocity limits --- .../config/default_task_settings.pbtxt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt index 87bf4a8cb..37fb20064 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_task_settings.pbtxt @@ -18,12 +18,12 @@ cartesian_limits { max_translational_position: 1.0 # y max_translational_position: 1.5 # z - min_translational_velocity: -0.25 - min_translational_velocity: -0.25 - min_translational_velocity: -0.25 - max_translational_velocity: 0.25 - max_translational_velocity: 0.25 - max_translational_velocity: 0.25 + min_translational_velocity: -0.75 + min_translational_velocity: -0.75 + min_translational_velocity: -0.75 + max_translational_velocity: 0.75 + max_translational_velocity: 0.75 + max_translational_velocity: 0.75 min_translational_acceleration: -10 min_translational_acceleration: -10 From 939dbf9f69b636fd36c3c7c0b094bc8a09dbffbe Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Thu, 30 Jul 2026 23:41:08 +0800 Subject: [PATCH 16/24] update default stiffness and damping parameters for joint impedance control --- .../config/default_joint_task_settings.pbtxt | 4 ++-- .../config/fixed_task_settings.json | 4 ++-- .../launch/test_joint_targets.launch.py | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt index 4e835c40a..11ef01d1d 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt +++ b/flowstate/aic_flowstate_ros_bridge/config/default_joint_task_settings.pbtxt @@ -26,10 +26,10 @@ interpolation_mode: REFLEXXES # Stiffness and damping cannot exceed the application limits. stiffness: { - joints: [100., 100., 100., 25., 25., 25.] + joints: [175., 175., 175., 125., 50., 50.] } damping: { - joints: [10.0, 10.0, 10.0, 5.0, 5.0, 5.0] + joints: [50.0, 50.0, 50.0, 35.0, 10.0, 10.0] } # Using ~50% of max_effort -- and this is could be more conservative. diff --git a/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json b/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json index 3ce02d7cc..451e23d0a 100644 --- a/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json +++ b/flowstate/aic_flowstate_ros_bridge/config/fixed_task_settings.json @@ -3,6 +3,6 @@ "target_pose_stiffness": [1000.0, 1000.0, 1000.0, 150.0, 150.0, 150.0], "target_pose_damping": [1562.049935, 1562.049935, 1562.049935, 1096.814453, 1096.814453, 1096.814453], "target_mass": [10.0, 10.0, 10.0, 5.0, 5.0, 5.0], - "target_joint_stiffness": [50.0, 50.0, 50.0, 10.0, 10.0, 10.0], - "target_joint_damping": [25.0, 25.0, 25.0, 5.0, 5.0, 5.0] + "target_joint_stiffness": [175.0, 175.0, 175.0, 125.0, 50.0, 50.0], + "target_joint_damping": [50.0, 50.0, 50.0, 35.0, 10.0, 10.0] } diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index d0ed814d8..81019ab75 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -30,20 +30,20 @@ def generate_launch_description(): "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json "target_joint_stiffness": [ + 175.0, + 175.0, + 175.0, + 125.0, 50.0, 50.0, + ], + "target_joint_damping": [ 50.0, + 50.0, + 50.0, + 35.0, 10.0, 10.0, - 10.0, - ], - "target_joint_damping": [ - 25.0, - 25.0, - 25.0, - 5.0, - 5.0, - 5.0, ], "publish_duration": 3.0, "stop_duration": 2.0, From 3bfbd50a2b714ed037058d6780a619382a64e0e5 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Thu, 30 Jul 2026 23:43:12 +0800 Subject: [PATCH 17/24] linting --- .../launch/test_pose_targets.launch.py | 2 +- .../src/robot_control_bridge.cpp | 53 +++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index e86d0bfb1..50d0e623c 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -97,7 +97,7 @@ def generate_launch_description(): 1562.049935, 1096.814453, 1096.814453, - 1096.814453 + 1096.814453, ], "publish_duration": 5.0, "stop_duration": 2.0, diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 34af9575c..36f070fd2 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -19,11 +19,11 @@ #include #include +#include #include +#include #include #include -#include -#include #include "absl/flags/flag.h" #include "absl/log/log.h" @@ -208,7 +208,10 @@ bool RobotControlBridge::initialize( #ifdef USE_FIXED_CONTROL_PARAMETERS { - std::filesystem::path fixed_json_path = ament_index_cpp::get_package_share_directory("aic_flowstate_ros_bridge") + "/config/fixed_task_settings.json"; + std::filesystem::path fixed_json_path = + ament_index_cpp::get_package_share_directory( + "aic_flowstate_ros_bridge") + + "/config/fixed_task_settings.json"; try { std::ifstream f(fixed_json_path.string()); if (!f.is_open()) { @@ -216,13 +219,20 @@ bool RobotControlBridge::initialize( } nlohmann::json config = nlohmann::json::parse(f); - auto target_pose_stiffness = config["target_pose_stiffness"].get>(); - auto target_pose_damping = config["target_pose_damping"].get>(); + auto target_pose_stiffness = + config["target_pose_stiffness"].get>(); + auto target_pose_damping = + config["target_pose_damping"].get>(); auto target_mass = config["target_mass"].get>(); - if (target_pose_stiffness.size() != 6 || target_pose_damping.size() != 6 || target_mass.size() != 6) { - LOG(ERROR) << "Fixed task settings: target_pose_stiffness, target_pose_damping, and target_mass must have exactly 6 elements."; - throw std::runtime_error("Fixed task settings must have exactly 6 elements for pose stiffness, damping, and mass."); + if (target_pose_stiffness.size() != 6 || + target_pose_damping.size() != 6 || target_mass.size() != 6) { + LOG(ERROR) << "Fixed task settings: target_pose_stiffness, " + "target_pose_damping, and target_mass must have exactly " + "6 elements."; + throw std::runtime_error( + "Fixed task settings must have exactly 6 elements for pose " + "stiffness, damping, and mass."); } auto* mu = data_->agent_bridge_fixed_params_.mutable_motion_update(); @@ -258,15 +268,22 @@ bool RobotControlBridge::initialize( target_mass_proto->set_data(35, target_mass[5]); } - auto target_joint_stiffness = config["target_joint_stiffness"].get>(); - auto target_joint_damping = config["target_joint_damping"].get>(); - - if (target_joint_stiffness.size() != 6 || target_joint_damping.size() != 6) { - LOG(ERROR) << "Fixed task settings: target_joint_stiffness and target_joint_damping must have exactly 6 elements."; - throw std::runtime_error("Fixed task settings must have exactly 6 elements for joint stiffness and damping."); + auto target_joint_stiffness = + config["target_joint_stiffness"].get>(); + auto target_joint_damping = + config["target_joint_damping"].get>(); + + if (target_joint_stiffness.size() != 6 || + target_joint_damping.size() != 6) { + LOG(ERROR) << "Fixed task settings: target_joint_stiffness and " + "target_joint_damping must have exactly 6 elements."; + throw std::runtime_error( + "Fixed task settings must have exactly 6 elements for joint " + "stiffness and damping."); } - auto* mu_joint = data_->agent_bridge_joint_fixed_params_.mutable_motion_update(); + auto* mu_joint = + data_->agent_bridge_joint_fixed_params_.mutable_motion_update(); auto* tjs = mu_joint->mutable_target_stiffness(); auto* tjd = mu_joint->mutable_target_damping(); tjs->clear_joints(); @@ -281,9 +298,11 @@ bool RobotControlBridge::initialize( std::string mode_str = config["control_mode"].get(); auto* ts = data_->agent_bridge_fixed_params_.mutable_task_settings(); if (mode_str == "admittance") { - ts->set_control_mode(intrinsic_proto::icon::actions::proto::ControlMode::ADMITTANCE); + ts->set_control_mode( + intrinsic_proto::icon::actions::proto::ControlMode::ADMITTANCE); } else if (mode_str == "impedance") { - ts->set_control_mode(intrinsic_proto::icon::actions::proto::ControlMode::IMPEDANCE); + ts->set_control_mode( + intrinsic_proto::icon::actions::proto::ControlMode::IMPEDANCE); } else { LOG(ERROR) << "Invalid control_mode: " << mode_str; throw std::runtime_error("Invalid control_mode parameter."); From 91cb8a5707838d7ea9610f77ad02a727e105ed39 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 4 Aug 2026 05:37:24 +0800 Subject: [PATCH 18/24] update changelog --- flowstate/aic_flowstate_ros_bridge/CHANGELOG.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flowstate/aic_flowstate_ros_bridge/CHANGELOG.rst b/flowstate/aic_flowstate_ros_bridge/CHANGELOG.rst index 0141f8e17..62e228525 100644 --- a/flowstate/aic_flowstate_ros_bridge/CHANGELOG.rst +++ b/flowstate/aic_flowstate_ros_bridge/CHANGELOG.rst @@ -2,8 +2,12 @@ Changelog for package aic_flowstate_ros_bridge ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.1.1 (2026-06-11) +0.1.1 (2026-08-04) ------------------ +* Expose tool transformation for FT sensor (`#603 `_) +* Subscribe to proto CaptureResults and publish ROS images (`#600 `_) +* Support admittance control (`#598 `_) +* Contributors: John TGZ, Kaushik Balasundar, Morgan Quigley 0.1.0 (2026-06-09) ------------------ From 6b3a2704669f6c3438de2614fafa1edd5e0e7e56 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 4 Aug 2026 05:39:37 +0800 Subject: [PATCH 19/24] clean up test scripts --- .../launch/test_joint_targets.launch.py | 13 ++-- .../launch/test_pose_targets.launch.py | 65 +------------------ 2 files changed, 7 insertions(+), 71 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py index 81019ab75..f9d6e62be 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_joint_targets.launch.py @@ -15,19 +15,14 @@ def generate_launch_description(): { "controller_namespace": "aic_controller", "test_mode": "joint", + # Example test_joint_targets format: JSON string of a flattened list of joint values (or list of lists). + # The list is automatically chunked into 6 values per joint target: [j1, j2, j3, j4, j5, j6] ########################## # Home position: ########################## - # "test_joint_targets": "[" - # "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" - # "]", - ########################## - # Test 1: - ########################## "test_joint_targets": "[" - "-1.27, -1.8, -1.47, -1.57, 1.57, -1.57," - # Home - "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" "]", + "-1.57, -1.57, -1.57, -1.57, 1.57, -1.57" + "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json "target_joint_stiffness": [ 175.0, diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index 50d0e623c..fdf6095cc 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -20,68 +20,9 @@ def generate_launch_description(): ########################## # Home position ########################## - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test contact - ########################## - # Pre-contact - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.175, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - # Contact! - # 'test_pose_targets': '[' - # '-0.1, -0.5, 0.155, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test 1 (position): - ########################## - # 'test_pose_targets': '[' - # '-0.5, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.5, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.3, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '0.15, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.2, -0.65, 0.25, 0.7071068, -0.7071068, 0.0, 0.0, ' - # '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - # ']', - ########################## - # Test 2 (pose): - ########################## - "test_pose_targets": "[" - "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # A: +45 x - "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # A: -45 x - "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # A: +45 y - "-0.5, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # A: -45 y - #### - "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # B: +45 x - "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # B: -45 x - "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # B: +45 y - "-0.5, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # B: -45 y - #### - "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # C: +45 x - "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # C: -45 x - "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # C: +45 y - "-0.2, -0.3, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # C: -45 y - #### - "0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # D: +45 x - "0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # D: -45 x - "0.0, -0.4, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # D: +45 y - "0.0, -0.4, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # D: -45 y - #### - "0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981," # E: +45 x - "0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981," # E: -45 x - "0.0, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981," # E: +45 y - "0.0, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # E: -45 y - #### - "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, -0.2705981, " # F: +45 x - "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, 0.2705981, " # F: -45 x - "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, -0.2705981, 0.2705981, " # F: +45 y - "-0.2, -0.6, 0.25, 0.6532815, -0.6532815, 0.2705981, -0.2705981," # F: -45 y - #### - "-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 " # Home - "]", + 'test_pose_targets': '[' + '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' + ']', "log_filepath": "", # Empty string defaults to tcp_accuracy_.json "target_pose_stiffness": [ 1000.0, From de3291af7ad95dc36bf799a877c79998e9bb379e Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 4 Aug 2026 05:39:51 +0800 Subject: [PATCH 20/24] set USE_FIXED_CONTROL_PARAMETERS to ON by default --- flowstate/aic_flowstate_ros_bridge/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt b/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt index 4c38e8fd5..5f23c665d 100644 --- a/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt +++ b/flowstate/aic_flowstate_ros_bridge/CMakeLists.txt @@ -35,7 +35,7 @@ find_package(Protobuf REQUIRED) find_package(orocos_kdl_vendor REQUIRED) #================================== -option(USE_FIXED_CONTROL_PARAMETERS "Use fixed control parameters" OFF) +option(USE_FIXED_CONTROL_PARAMETERS "Use fixed control parameters" ON) if(USE_FIXED_CONTROL_PARAMETERS) add_compile_definitions(USE_FIXED_CONTROL_PARAMETERS) endif() From ac8d395a22d12f7d8d778f7377f0a2437be5c886 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Tue, 4 Aug 2026 05:41:24 +0800 Subject: [PATCH 21/24] linting --- .../launch/test_pose_targets.launch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py index fdf6095cc..3a82bf078 100644 --- a/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py +++ b/flowstate/aic_flowstate_ros_bridge/launch/test_pose_targets.launch.py @@ -20,9 +20,9 @@ def generate_launch_description(): ########################## # Home position ########################## - 'test_pose_targets': '[' - '-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 ' - ']', + "test_pose_targets": "[" + "-0.1, -0.5, 0.5, 0.7071068, -0.7071068, 0.0, 0.0 " + "]", "log_filepath": "", # Empty string defaults to tcp_accuracy_.json "target_pose_stiffness": [ 1000.0, From e46554669584e75c0699a2e66b4a5d2da7ae2d16 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 5 Aug 2026 07:23:52 +0800 Subject: [PATCH 22/24] fix bug where only the first 2 values of the pose stiffness and damping are being used --- .../scripts/test_robot_control_bridge.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py index a0849d32c..775fb1151 100755 --- a/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py +++ b/flowstate/aic_flowstate_ros_bridge/scripts/test_robot_control_bridge.py @@ -70,20 +70,27 @@ def __init__(self): self.log_filepath = self.declare_parameter("log_filepath", "").value - stiffness_param = self.declare_parameter( - "target_pose_stiffness", [10.0, 10.0] + self.target_pose_stiffness = self.declare_parameter( + "target_pose_stiffness", [1000.0, 1000.0, 1000.0, 150.0, 150.0, 150.0] + ).value + self.target_pose_damping = self.declare_parameter( + "target_pose_damping", + [ + 1562.049935, + 1562.049935, + 1562.049935, + 1096.814453, + 1096.814453, + 1096.814453, + ], ).value - self.target_pose_stiffness = [stiffness_param[0]] * 3 + [stiffness_param[1]] * 3 - - damping_param = self.declare_parameter("target_pose_damping", [5.0, 5.0]).value - self.target_pose_damping = [damping_param[0]] * 3 + [damping_param[1]] * 3 self.target_joint_stiffness = self.declare_parameter( - "target_joint_stiffness", [50.0, 50.0, 50.0, 10.0, 10.0, 10.0] + "target_joint_stiffness", [175.0, 175.0, 175.0, 125.0, 50.0, 50.0] ).value self.target_joint_damping = self.declare_parameter( - "target_joint_damping", [25.0, 25.0, 25.0, 5.0, 5.0, 5.0] + "target_joint_damping", [50.0, 50.0, 50.0, 35.0, 10.0, 10.0] ).value self.publish_duration = self.declare_parameter("publish_duration", 5.0).value From c2b021bc2c1e0dd4c95f89990af4971564e469ad Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 5 Aug 2026 07:38:17 +0800 Subject: [PATCH 23/24] refactor stiffness, damping and mass diagonal matrix assignments to use SetDiagonal6x6 --- .../src/robot_control_bridge.cpp | 72 +++++++------------ 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 36f070fd2..3061e9220 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -64,6 +64,25 @@ constexpr const char* kTimeToTargetSecondsParamName = "time_to_target_seconds"; constexpr const char* kControlModeParamName = "control_mode"; constexpr const char* kCriticalMassParamName = "critical_mass"; +namespace { + +inline void SetDiagonal6x6(google::protobuf::RepeatedField* field, + const std::vector& diag) { + field->Clear(); + field->Resize(36, 0.0); + for (int i = 0; i < 6; ++i) { + field->Set(i * 7, diag[i]); + } +} + +inline void SetDiagonal6x6(google::protobuf::RepeatedField* field, + const intrinsic_proto::icon::CartVec6& diag) { + SetDiagonal6x6(field, {diag.x(), diag.y(), diag.z(), diag.rx(), diag.ry(), + diag.rz()}); +} + +} // namespace + ///============================================================================= void RobotControlBridge::declare_ros_parameters( ROSNodeInterfaces ros_node_interfaces) { @@ -239,34 +258,9 @@ bool RobotControlBridge::initialize( auto* target_stiffness = mu->mutable_target_stiffness(); auto* target_damping = mu->mutable_target_damping(); auto* target_mass_proto = mu->mutable_target_mass(); - target_stiffness->mutable_data()->Resize(36, 0.0); - target_damping->mutable_data()->Resize(36, 0.0); - target_mass_proto->mutable_data()->Resize(36, 0.0); - - if (target_pose_stiffness.size() >= 6) { - target_stiffness->set_data(0, target_pose_stiffness[0]); - target_stiffness->set_data(7, target_pose_stiffness[1]); - target_stiffness->set_data(14, target_pose_stiffness[2]); - target_stiffness->set_data(21, target_pose_stiffness[3]); - target_stiffness->set_data(28, target_pose_stiffness[4]); - target_stiffness->set_data(35, target_pose_stiffness[5]); - } - if (target_pose_damping.size() >= 6) { - target_damping->set_data(0, target_pose_damping[0]); - target_damping->set_data(7, target_pose_damping[1]); - target_damping->set_data(14, target_pose_damping[2]); - target_damping->set_data(21, target_pose_damping[3]); - target_damping->set_data(28, target_pose_damping[4]); - target_damping->set_data(35, target_pose_damping[5]); - } - if (target_mass.size() >= 6) { - target_mass_proto->set_data(0, target_mass[0]); - target_mass_proto->set_data(7, target_mass[1]); - target_mass_proto->set_data(14, target_mass[2]); - target_mass_proto->set_data(21, target_mass[3]); - target_mass_proto->set_data(28, target_mass[4]); - target_mass_proto->set_data(35, target_mass[5]); - } + SetDiagonal6x6(target_stiffness->mutable_data(), target_pose_stiffness); + SetDiagonal6x6(target_damping->mutable_data(), target_pose_damping); + SetDiagonal6x6(target_mass_proto->mutable_data(), target_mass); auto target_joint_stiffness = config["target_joint_stiffness"].get>(); @@ -1042,27 +1036,11 @@ bool RobotControlBridge::resetMotionUpdate() { const auto& max_damping = data_->agent_bridge_fixed_params_.task_settings().max_damping(); - target_stiffness->set_data(0, max_stiffness.x()); - target_stiffness->set_data(7, max_stiffness.y()); - target_stiffness->set_data(14, max_stiffness.z()); - target_stiffness->set_data(21, max_stiffness.rx()); - target_stiffness->set_data(28, max_stiffness.ry()); - target_stiffness->set_data(35, max_stiffness.rz()); - - target_damping->set_data(0, max_damping.x()); - target_damping->set_data(7, max_damping.y()); - target_damping->set_data(14, max_damping.z()); - target_damping->set_data(21, max_damping.rx()); - target_damping->set_data(28, max_damping.ry()); - target_damping->set_data(35, max_damping.rz()); + SetDiagonal6x6(target_stiffness->mutable_data(), max_stiffness); + SetDiagonal6x6(target_damping->mutable_data(), max_damping); if (data_->critical_mass_.size() >= 6) { - target_mass->set_data(0, data_->critical_mass_[0]); - target_mass->set_data(7, data_->critical_mass_[1]); - target_mass->set_data(14, data_->critical_mass_[2]); - target_mass->set_data(21, data_->critical_mass_[3]); - target_mass->set_data(28, data_->critical_mass_[4]); - target_mass->set_data(35, data_->critical_mass_[5]); + SetDiagonal6x6(target_mass->mutable_data(), data_->critical_mass_); } else { LOG(ERROR) << "critical_mass parameter does not have 6 elements."; return false; From 50c9fb2734d972cbdb4f39142473a37470ff1ec0 Mon Sep 17 00:00:00 2001 From: JohnTGZ Date: Wed, 5 Aug 2026 07:39:09 +0800 Subject: [PATCH 24/24] linting --- .../aic_flowstate_ros_bridge/src/robot_control_bridge.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp index 3061e9220..c6594f9b8 100644 --- a/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp +++ b/flowstate/aic_flowstate_ros_bridge/src/robot_control_bridge.cpp @@ -77,8 +77,8 @@ inline void SetDiagonal6x6(google::protobuf::RepeatedField* field, inline void SetDiagonal6x6(google::protobuf::RepeatedField* field, const intrinsic_proto::icon::CartVec6& diag) { - SetDiagonal6x6(field, {diag.x(), diag.y(), diag.z(), diag.rx(), diag.ry(), - diag.rz()}); + SetDiagonal6x6( + field, {diag.x(), diag.y(), diag.z(), diag.rx(), diag.ry(), diag.rz()}); } } // namespace