Add admittance controller configuration. lyrical
authorWalter Fetter Lages <w.fetter@ieee.org>
Fri, 6 Nov 2026 05:29:08 +0000 (02:29 -0300)
committerWalter Fetter Lages <w.fetter@ieee.org>
Fri, 6 Nov 2026 05:29:08 +0000 (02:29 -0300)
q2d_bringup/config/admittance.yaml [new file with mode: 0644]
q2d_bringup/config/controller_manager.yaml [new file with mode: 0644]
q2d_bringup/config/force_torque_sensor_broadcaster.yaml [new file with mode: 0644]
q2d_bringup/launch/admittance.launch.xml [new file with mode: 0644]
q2d_description/urdf/q2d.urdf

diff --git a/q2d_bringup/config/admittance.yaml b/q2d_bringup/config/admittance.yaml
new file mode 100644 (file)
index 0000000..d92001d
--- /dev/null
@@ -0,0 +1,87 @@
+admittance_controller:
+        ros__parameters:
+                type: admittance_controller/AdmittanceController
+                joints:
+                        - shoulder_active_joint
+                        - elbow_active_joint
+                command_joints:
+                        - motion_controller/shoulder_active_joint
+                        - motion_controller/elbow_active_joint
+                command_interfaces:
+                        - position
+                state_interfaces:
+                        - position
+                        # - velocity
+                chainable_command_interfaces:
+                        - position
+                        # - velocity
+                kinematics:
+                        plugin_name: kinematics_interface_kdl/KinematicsInterfaceKDL
+                        plugin_package: kinematics_interface
+                        base: base_link
+                        tip: tool_link
+#                        alpha: 0.01
+                        alpha: 0.0005
+                ft_sensor:
+                        name: ft_sensor
+                        frame:
+                                id: tool_link
+#                        filter_coefficient: 0.05
+                        filter_coefficient: 0.005
+                control:
+                        frame:
+                                id: tool_link
+                fixed_world_frame:
+                        frame:
+                                id: base_link
+                gravity_compensation:
+                        frame:
+                                id: tool_link
+                        CoG:
+                                pos:
+                                        - 0.06204831581
+                                        - 0.00000013809
+                                        - 0.01489882531
+                                force: 6.6246160665465 # mass*9.81
+                admittance:
+                        selected_axes:
+                                - true
+                                - true
+                                - false
+                                - false
+                                - false
+                                - true
+                        mass:
+                                - 0.5
+                                - 0.5
+                                - 0.5
+                                - 0.05
+                                - 0.05
+                                - 0.05
+                        damping_ratio:   # xi = D / (2 * sqrt( M * S ))
+                                - 1.0
+                                - 1.0
+                                - 1.0
+                                - 1.0
+                                - 1.0
+                                - 1.0 
+                        stiffness:
+                                - 250.0
+                                - 250.0
+                                - 250.0
+                                - 250.0
+                                - 250.0
+                                - 250.0
+                enable_parameter_update_without_reactivation: true        
+
+motion_controller:
+        ros__parameters:
+                type: pid_controller/PidController
+                dof_names:
+                        - shoulder_active_joint
+                        - elbow_active_joint
+                command_interface: effort
+                reference_and_state_interfaces: ["position"]
+                gains:
+                        shoulder_active_joint: {p: 2310.0, i: 4640.0, d: 0.299, i_clamp_max: 100.0, i_clamp_min: -100.0, antiwindup: false}
+                        elbow_active_joint: {p: 339.0, i: 841.0, d: 0.351, i_clamp_max: 100.0, i_clamp_min: -100.0, antiwindup: false}
diff --git a/q2d_bringup/config/controller_manager.yaml b/q2d_bringup/config/controller_manager.yaml
new file mode 100644 (file)
index 0000000..060c83c
--- /dev/null
@@ -0,0 +1,5 @@
+controller_manager:
+        ros__parameters:
+                update_rate: 100
+                enforce_command_limits: false
+                use_sim_time: false
diff --git a/q2d_bringup/config/force_torque_sensor_broadcaster.yaml b/q2d_bringup/config/force_torque_sensor_broadcaster.yaml
new file mode 100644 (file)
index 0000000..6d06db3
--- /dev/null
@@ -0,0 +1,5 @@
+ft_sensor_broadcaster:
+        ros__parameters:
+                type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster
+                sensor_name: ft_sensor
+                frame_id: tool_llink
diff --git a/q2d_bringup/launch/admittance.launch.xml b/q2d_bringup/launch/admittance.launch.xml
new file mode 100644 (file)
index 0000000..8678fcc
--- /dev/null
@@ -0,0 +1,33 @@
+<!--******************************************************************************
+                          Quanser 2DSFJE Bringup
+                      Admittance Controller Launch File
+          Copyright (C) 2026 Walter Fetter Lages <w.fetter@ieee.org>
+
+        This program is free software: you can redistribute it and/or modify
+        it under the terms of the GNU General Public License as published by
+        the Free Software Foundation, either version 3 of the License, or
+        (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful, but
+        WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+        Geneal Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this program.  If not, see
+        <http://www.gnu.org/licenses/>.
+        
+*******************************************************************************-->
+
+<launch>
+       <arg name="config" default="$(find-pkg-share q2d_bringup)/config/admittance.yaml"/>
+       
+       <node name="admittance_controller_spawner" pkg="controller_manager" exec="spawner"
+               args="-p $(var config) --activate-as-group motion_controller admittance_controller"/>
+               
+       <node name="joint_state_broadcaster_spawner" pkg="controller_manager" exec="spawner"
+               args="-p $(find-pkg-share q2d_bringup)/config/joint_state_broadcaster.yaml joint_state_broadcaster"/>
+
+       <node name="ft_sensor_broadcaster_spawner" pkg="controller_manager" exec="spawner"
+               args="-p $(find-pkg-share q2d_bringup)/config/force_torque_sensor_broadcaster.yaml ft_sensor_broadcaster"/>
+</launch>
index 9b4dd72..012d1b5 100644 (file)
                </visual>
        </gazebo>
 
+       <gazebo>
+               <plugin filename="gz-sim-forcetorque-system" name="gz::sim::systems::ForceTorque"/>
+       </gazebo>
+
+       <gazebo reference="elbow_passive_joint">
+               <!-- The child link should have inertia -->
+               <!-- elbow_passive_joint is a fixed joint, preserve it -->
+               <preserveFixedJoint>true</preserveFixedJoint>
+               <sensor name="ft_sensor" type="force_torque">
+                       <update_rate>50.0</update_rate>
+                       <always_on>true</always_on>
+                       <visualize>true</visualize>
+                       <topic>ft_sensor/wrench</topic>
+                       <pose>0 0 0 0 0 0</pose>
+               </sensor>
+       </gazebo>
+
        <ros2_control name="Q2dSystem" type="system">
                <xacro:if value="${hardware == 'gazebo'}">
                        <hardware>
                                <plugin>q2d_hardware/Q2dSystemHardware</plugin>
                        </hardware>
                </xacro:if>
+               <xacro:if value="${hardware == 'sim_hardware'}">
+                       <hardware>
+                               <plugin>sim_hardware/SimSystemHardware</plugin>
+                       </hardware>
+               </xacro:if>
+               <xacro:if value="${hardware == 'topic_hardware'}">
+                       <hardware>
+                               <plugin>joint_state_topic_hardware_interface/JointStateTopicSystem</plugin>
+                               <param name="joint_commands_topic">joint_commands</param>
+                               <param name="joint_states_topic">joint_states</param>
+                               <param name="sum_wrapped_joint_states">false</param>
+                               <param name="trigger_joint_commands_threshold">-1</param>
+                       </hardware>
+               </xacro:if>
 
                <joint name="shoulder_active_joint">
                        <command_interface name="effort">
                        <state_interface name="velocity"/>
                        <state_interface name="effort"/>
                </joint>
+
+               <sensor name="ft_sensor" type="force_torque">
+                       <state_interface name="force.x"/>
+                       <state_interface name="force.y"/>
+                       <state_interface name="force.z"/>
+                       <state_interface name="torque.x"/>
+                       <state_interface name="torque.y"/>
+                       <state_interface name="torque.z"/>
+               </sensor>
        </ros2_control>
 
        <gazebo>