Skip to content

Commit

Permalink
Added inertial properties of links with macro taken from franka_ros.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteMuc committed May 4, 2024
1 parent 75d8802 commit 1b8c9fc
Show file tree
Hide file tree
Showing 13 changed files with 791 additions and 78 deletions.
44 changes: 36 additions & 8 deletions my_panda_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@

from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare

from launch.conditions import IfCondition, UnlessCondition
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
#1
# 1
load_gripper = LaunchConfiguration("load_gripper")
declare_load_gripper_arg = DeclareLaunchArgument(
"load_gripper",
default_value="False",
description="Use Franka Gripper as end-effector if True",
)
#2
# 2
robot_ip = LaunchConfiguration("robot_ip")
declare_robot_ip_arg = DeclareLaunchArgument(
"robot_ip",
Expand All @@ -39,21 +38,49 @@ def generate_launch_description():
description="Whether simulation is used",
)

#4
# 4
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
declare_use_fake_hardware_arg = DeclareLaunchArgument(
"use_fake_hardware",
default_value="False",
description="Wheter to use fake hardware",
)
#5
# 5
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
declare_fake_sensor_commands_arg = DeclareLaunchArgument(
"fake_sensor_commands",
default_value="False",
description="Wheter to use fake sensor commands",
)

# 6: Real Robot flag to launch or not Franka bringup (franka.launch.py)
real_robot = LaunchConfiguration("real_robot")
declare_real_robot_arg = DeclareLaunchArgument(
"real_robot",
default_value="False",
description="Whether to use real robot. If true, launch the FCI franka interface.",
)

## Include franka.launch.py

franka_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[
get_package_share_directory("my_panda_bringup"),
"launch",
"franka.launch.py"
]
)
),
launch_arguments={
"load_gripper": load_gripper,
"robot_ip": robot_ip,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands
}.items(),
condition=UnlessCondition(use_fake_hardware),
)

# controller_launch = IncludeLaunchDescription(
# PythonLaunchDescriptionSource(
Expand Down Expand Up @@ -95,16 +122,17 @@ def generate_launch_description():
}.items(),
)


actions = [
declare_real_robot_arg,
declare_load_gripper_arg,
declare_robot_ip_arg,
declare_use_sim_arg,
declare_use_fake_hardware_arg,
declare_fake_sensor_commands_arg,
SetParameter(name="use_sim_time", value=use_sim),
# controller_launch,
moveit_launch
moveit_launch, ## Launch the move group node.
franka_launch ## Launch Franka Bringup if using real robot (FCI).
]

return LaunchDescription(actions)
121 changes: 121 additions & 0 deletions my_panda_bringup/launch/franka.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env python3

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, Shutdown
from launch.conditions import IfCondition, UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

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'
use_rviz_parameter_name = 'use_rviz'

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)
use_rviz = LaunchConfiguration(use_rviz_parameter_name)

franka_xacro_file = os.path.join(get_package_share_directory('my_panda_description'), 'robots',
'panda_arm.urdf.xacro')
robot_description = Command(
[FindExecutable(name='xacro'), ' ', franka_xacro_file, ' hand:=', load_gripper,
' robot_ip:=', robot_ip, ' use_fake_hardware:=', use_fake_hardware,
' fake_sensor_commands:=', fake_sensor_commands])

rviz_file = os.path.join(get_package_share_directory('my_panda_viz'), 'rviz',
'visualize_franka.rviz')

franka_controllers = PathJoinSubstitution(
[
FindPackageShare('my_panda_controller'),
'config',
'controllers.yaml',
]
)

return LaunchDescription([
DeclareLaunchArgument(
robot_ip_parameter_name,
description='Hostname or IP address of the robot.'),
DeclareLaunchArgument(
use_rviz_parameter_name,
default_value='false',
description='Visualize the robot in Rviz'),
DeclareLaunchArgument(
use_fake_hardware_parameter_name,
default_value='false',
description='Use fake hardware'),
DeclareLaunchArgument(
fake_sensor_commands_parameter_name,
default_value='false',
description="Fake sensor commands. Only valid when '{}' is true".format(
use_fake_hardware_parameter_name)),
DeclareLaunchArgument(
load_gripper_parameter_name,
default_value='true',
description='Use Franka Gripper as an end-effector, otherwise, the robot is loaded '
'without an end-effector.'),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{'robot_description': robot_description}],
),
Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher',
parameters=[
{'source_list': ['franka/joint_states', 'panda_gripper/joint_states'],
'rate': 30}],
),
Node(
package='controller_manager',
executable='ros2_control_node',
parameters=[{'robot_description': robot_description}, franka_controllers],
remappings=[('joint_states', 'franka/joint_states')],
output={
'stdout': 'screen',
'stderr': 'screen',
},
on_exit=Shutdown(),
),
Node(
package='controller_manager',
executable='spawner',
arguments=['joint_state_broadcaster'],
output='screen',
),
Node(
package='controller_manager',
executable='spawner',
arguments=['franka_robot_state_broadcaster'],
output='screen',
condition=UnlessCondition(use_fake_hardware),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([PathJoinSubstitution(
[FindPackageShare('franka_gripper'), 'launch', 'gripper.launch.py'])]),
launch_arguments={robot_ip_parameter_name: robot_ip,
use_fake_hardware_parameter_name: use_fake_hardware}.items(),
condition=IfCondition(load_gripper)
),

Node(package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['--display-config', rviz_file],
condition=IfCondition(use_rviz)
)

])
139 changes: 139 additions & 0 deletions my_panda_controller/config/controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
controller_manager:
ros__parameters:
update_rate: 1000 # Hz

gravity_compensation_example_controller:
type: franka_example_controllers/GravityCompensationExampleController

joint_impedance_example_controller:
type: franka_example_controllers/JointImpedanceExampleController

joint_velocity_example_controller:
type: franka_example_controllers/JointVelocityExampleController

joint_position_example_controller:
type: franka_example_controllers/JointPositionExampleController

cartesian_velocity_example_controller:
type: franka_example_controllers/CartesianVelocityExampleController

cartesian_pose_example_controller:
type: franka_example_controllers/CartesianPoseExampleController

cartesian_pose_elbow_example_controller:
type: franka_example_controllers/CartesianElbowExampleController

joint_impedance_with_ik_example_controller:
type: franka_example_controllers/JointImpedanceWithIKExampleController

cartesian_orientation_example_controller:
type: franka_example_controllers/CartesianOrientationExampleController

elbow_example_controller:
type: franka_example_controllers/ElbowExampleController

move_to_start_example_controller:
type: franka_example_controllers/MoveToStartExampleController

model_example_controller:
type: franka_example_controllers/ModelExampleController

joint_trajectory_controller:
type: joint_trajectory_controller/JointTrajectoryController

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

franka_robot_state_broadcaster:
type: franka_robot_state_broadcaster/FrankaRobotStateBroadcaster

joint_impedance_with_ik_example_controller:
ros__parameters:
arm_id: panda
k_gains:
- 600.0
- 600.0
- 600.0
- 600.0
- 250.0
- 150.0
- 50.0
d_gains:
- 30.0
- 30.0
- 30.0
- 30.0
- 10.0
- 10.0
- 5.

franka_robot_state_broadcaster:
ros__parameters:
arm_id: panda

model_example_controller:
ros__parameters:
arm_id: panda

joint_trajectory_controller:
ros__parameters:
joints:
- panda_joint1
- panda_joint2
- panda_joint3
- panda_joint4
- panda_joint5
- panda_joint6
- panda_joint7
command_interfaces:
- effort
state_interfaces:
- position
- velocity
gains:
panda_joint1: { p: 600., d: 30., i: 0., i_clamp: 1. }
panda_joint2: { p: 600., d: 30., i: 0., i_clamp: 1. }
panda_joint3: { p: 600., d: 30., i: 0., i_clamp: 1. }
panda_joint4: { p: 600., d: 30., i: 0., i_clamp: 1. }
panda_joint5: { p: 250., d: 10., i: 0., i_clamp: 1. }
panda_joint6: { p: 150., d: 10., i: 0., i_clamp: 1. }
panda_joint7: { p: 50., d: 5., i: 0., i_clamp: 1. }

joint_impedance_example_controller:
ros__parameters:
arm_id: panda
k_gains:
- 24.0
- 24.0
- 24.0
- 24.0
- 10.0
- 6.0
- 2.0
d_gains:
- 2.0
- 2.0
- 2.0
- 1.0
- 1.0
- 1.0
- 0.5
move_to_start_example_controller:
ros__parameters:
arm_id: panda
k_gains:
- 600.0
- 600.0
- 600.0
- 600.0
- 250.0
- 150.0
- 50.0
d_gains:
- 30.0
- 30.0
- 30.0
- 30.0
- 10.0
- 10.0
- 5.
1 change: 1 addition & 0 deletions my_panda_controller/config/panda_ros_controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ panda_arm_controller:
state_interfaces:
- position
- velocity
- acceleration

state_publish_rate: 50.0 # Defaults to 50
action_monitor_rate: 20.0 # Defaults to 20
Expand Down
Loading

0 comments on commit 1b8c9fc

Please sign in to comment.