Skip to content

Commit

Permalink
fix: joint_impedance_with_ik works with and without gripper
Browse files Browse the repository at this point in the history
  • Loading branch information
winkma committed Sep 27, 2024
1 parent 329d4c4 commit bd03390
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions franka_bringup/launch/franka.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def robot_description_dependent_nodes_spawner(
parameters=[franka_controllers,
{'robot_description': robot_description},
{'arm_id': arm_id},
{'load_gripper': load_gripper},
],
remappings=[('joint_states', 'franka/joint_states')],
output={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class JointImpedanceWithIKExampleController : public controller_interface::Contr
bool initialization_flag_{true};

std::string arm_id_;
bool is_gripper_loaded_ = true;

double elapsed_time_{0.0};
std::unique_ptr<franka_semantic_components::FrankaRobotModel> franka_robot_model_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ JointImpedanceWithIKExampleController::create_ik_service_request(
service_request->ik_request.robot_state.joint_state.velocity = joint_velocities_current;
service_request->ik_request.robot_state.joint_state.effort = joint_efforts_current;

// If Franka Hand is not connected, the following line should be commented out.
service_request->ik_request.ik_link_name = arm_id_ + "_hand_tcp";
if (is_gripper_loaded_) {
service_request->ik_request.ik_link_name = arm_id_ + "_hand_tcp";
}
return service_request;
}

Expand Down Expand Up @@ -189,6 +190,8 @@ CallbackReturn JointImpedanceWithIKExampleController::on_init() {

bool JointImpedanceWithIKExampleController::assign_parameters() {
arm_id_ = get_node()->get_parameter("arm_id").as_string();
is_gripper_loaded_ = get_node()->get_parameter("load_gripper").as_bool();

auto k_gains = get_node()->get_parameter("k_gains").as_double_array();
auto d_gains = get_node()->get_parameter("d_gains").as_double_array();
if (k_gains.empty()) {
Expand Down
7 changes: 5 additions & 2 deletions franka_fr3_moveit_config/launch/move_group.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ def load_yaml(package_name, file_path):

def generate_launch_description():
robot_ip_parameter_name = 'robot_ip'
load_gripper_parameter_name = 'load_gripper'
use_fake_hardware_parameter_name = 'use_fake_hardware'
fake_sensor_commands_parameter_name = 'fake_sensor_commands'

robot_ip = LaunchConfiguration(robot_ip_parameter_name)
load_gripper = LaunchConfiguration(load_gripper_parameter_name)
use_fake_hardware = LaunchConfiguration(use_fake_hardware_parameter_name)
fake_sensor_commands = LaunchConfiguration(
fake_sensor_commands_parameter_name)
Expand All @@ -62,7 +64,8 @@ def generate_launch_description():
' ',
franka_xacro_file,
' ros2_control:=false',
' hand:=true',
' hand:=',
load_gripper,
' arm_id:=fr3',
' robot_ip:=',
robot_ip,
Expand All @@ -83,7 +86,7 @@ def generate_launch_description():

robot_description_semantic_command = Command(
[FindExecutable(name='xacro'), ' ',
franka_semantic_xacro_file, ' hand:=true']
franka_semantic_xacro_file, ' hand:=', load_gripper]
)

# Use ParameterValue here as well if needed
Expand Down
2 changes: 1 addition & 1 deletion franka_fr3_moveit_config/srdf/fr3_arm.srdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="fr3">

<xacro:arg name="arm_id" default="fr3"/>
<xacro:arg name="hand" default="true"/> <!-- Should a franka_gripper be mounted at the flange? (Currently does not work without it) -->
<xacro:arg name="hand" default="true"/>

<xacro:property name="arm_id" value="$(arg arm_id)"/>

Expand Down

0 comments on commit bd03390

Please sign in to comment.