my urdf file -
<?xml version="1.0"?><xacro:include filename="$(find arm_simulation)/urdf/robot.xacro"/>
<!-- fixing the arm to the base -->
<link name="world" />
<joint name="fixed" type="fixed">
<parent link="world"/>
<child link="base_link"/>
</joint>
<!--
<link name="base_link">
<visual>
<geometry>
<cylinder radius="0.1" length="0.05"/>
</geometry>
<origin xyz="0.0 0.0 0.025 " rpy="0.0 0.0 0.0"/>
</visual>
<collision>
<geometry>
<cylinder radius="0.1" length="0.05"/>
</geometry>
<origin xyz="0.0 0.0 0.025 " rpy="0.0 0.0 0.0"/>
</collision>
</link>
-->
<xacro:arm_link_cylinder name = "base_link" origin_xyz = "0.0 0.0 0.025" origin_rpy = "0.0 0.0 0.0"
radius = "0.1" length = "0.05"
mass = "1" ixx = "0.0001" ixy = "0" ixz ="0"
iyy = "0.0001" iyz = "0"
izz = "0.0001" />
<xacro:arm_link_cylinder name = "link_1" origin_xyz = "0.0 0.0 0.132" origin_rpy = "0.0 0.0 0.0"
radius = "0.05" length = "0.264"
mass = "1.5" ixx = "0.054147" ixy = "0" ixz ="0"
iyy = "0.054147" iyz = "0"
izz = "0.001875"
/>
<!-- <joint name="base_link__link_1" type="revolute">
<parent link="base_link"/>
<child link="link_1"/>
<axis xyz="0 0 1"/>
<limit lower="-3.14159" upper="3.14159" velocity="0.5" effort="1000.0"/>
<origin xyz="0 0 0.05" rpy="0 0 0"/>
</joint> -->
<xacro:arm_joint name = "base_link__link_1" type = "revolute" parent = "base_link" child = "link_1"
axis = "0 0 1" lower_limit = "-3.14" upper_limit = "3.14"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 0 0.05" origin_rpy = "0 0 0"
/>
<xacro:arm_link_cylinder name = "link_2" origin_xyz = "0.0 0.0 0.425" origin_rpy = "0.0 0.0 0.0"
radius = "0.05" length = "0.85"
mass = "2" ixx = "0.12167" ixy = "0" ixz ="0"
iyy = "0.12167" iyz = "0"
izz = "0.0025"
/>
<xacro:arm_joint name = "link_1__link_2" type = "revolute" parent = "link_1" child = "link_2"
axis = "0 1 0" lower_limit = "-3.14" upper_limit = "2.5"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 0.1 0.214" origin_rpy = "0 0 0"
/>
<!-- <xacro:arm_link_cylinder name = "link_3" origin_xyz = "0.0 0.0 0.34" origin_rpy = "0.0 0.0 0.0"
radius = "0.05" length = "0.68"
mass = "2" ixx = "0.07832" ixy = "0" ixz ="0"
iyy = "0.07832" iyz = "0"
izz = "0.0025"
/>
<xacro:arm_joint name = "link_2__link_3" type = "revolute" parent = "link_2" child = "link_3"
axis = "0 1 0" lower_limit = "-3.14" upper_limit = "3.14"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 -0.1 0.8" origin_rpy = "0 0 0"
/>
<xacro:arm_link_cylinder name = "link_4" origin_xyz = "0.0 0.0 0.065" origin_rpy = "0.0 0.0 0.0"
radius = "0.05" length = "0.13"
mass = "1" ixx = "0.00565" ixy = "0" ixz ="0"
iyy = "0.0" iyz = "0"
izz = "0.00565"
/>
<xacro:arm_joint name = "link_3__link_4" type = "revolute" parent = "link_3" child = "link_4"
axis = "0 1 0" lower_limit = "-3.14" upper_limit = "3.14"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 -0.1 0.638" origin_rpy = "0 0 0"
/>
<xacro:arm_link_cylinder name = "link_5" origin_xyz = "0.0 0.0 0.035" origin_rpy = "0.0 0.0 0.0"
radius = "0.05" length = "0.17"
mass = "2" ixx = "0.4816" ixy = "0" ixz ="0"
iyy = "0.0" iyz = "0"
izz = "0.4816"
/>
<xacro:arm_joint name = "link_4__link_5" type = "revolute" parent = "link_4" child = "link_5"
axis = "1 0 0" lower_limit = "-3.14" upper_limit = "3.14"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 0.0 0.180" origin_rpy = "0 1.57 0"
/>
→
<!-- end effector config -->
<!-- <xacro:arm_link_box name = "tcp_connector" size = "0.03 0.15 0.03"
origin_xyz = "0.0 0.0 0.0125" origin_rpy = "0.0 0.0 0.0"
mass = "1" ixx = "0.00195" ixy = "0" ixz ="0"
iyy = "0.00195" iyz = "0"
izz = "0.00015"
/>
<xacro:arm_joint name = "link_5__tcp_connector" type = "revolute" parent = "link_5" child = "tcp_connector"
axis = "0 0 1" lower_limit = "-3.14" upper_limit = "3.14"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 0.0 0.120" origin_rpy = "0 0 0"
/>
<xacro:arm_link_box name = "gripper_right" size = "0.01 0.01 0.1"
origin_xyz = "0.0 0.0 0.05" origin_rpy = "0.0 0.0 0.0"
mass = "0.5" ixx = "0.00042" ixy = "0" ixz ="0"
iyy = "0.00042" iyz = "0"
izz = "0.0000083"
/>
<xacro:arm_joint name = "tcp_connector_gripper_right" type = "prismatic" parent = "tcp_connector" child = "gripper_right"
axis = "0 1 0" lower_limit = "0" upper_limit = "0.055"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 -0.065 0.03" origin_rpy = "0 0 0"
/>
<xacro:arm_link_box name = "gripper_left" size = "0.01 0.01 0.1"
origin_xyz = "0.0 0.0 0.05" origin_rpy = "0.0 0.0 0.0"
mass = "0.5" ixx = "0.00042" ixy = "0" ixz ="0"
iyy = "0.00042" iyz = "0"
izz = "0.0000083"
/>
<xacro:arm_joint name = "tcp_connector_gripper_left" type = "prismatic" parent = "tcp_connector" child = "gripper_left"
axis = "0 1 0" lower_limit = "0" upper_limit = "-0.055"
vel_limit = "0.5" eff_limit = "1000.0"
origin_xyz = "0 0.065 0.03" origin_rpy = "0 0 0"
/> -->
<!-- transmission in every joint -->
<xacro:transmission name = "transmission_base_link__link_1"
joint_name = "base_link__link_1"
actuator_name = "motor_base_link__link_1" />
<xacro:transmission name = "transmission_link_1__link_2"
joint_name = "link_1__link_2"
actuator_name = "motor_link_1__link_2" />
<!-- <xacro:transmission name = "transmission_link_2_link_3"
joint_name = "link_2__link_3"
actuator_name = "motor_link_2__link_3" />
<xacro:transmission name = "transmission_link_3__link_4"
joint_name = "link_3__link_4"
actuator_name = "motor_link_3__link_4" />
<xacro:transmission name = "transmission_link_4__link_5"
joint_name = "link_4__link_5"
actuator_name = "motor_link_4__link_5" />
<xacro:transmission name = "transmission_link_5__tcp_connector"
joint_name = "link_5__tcp_connector"
actuator_name = "link_5__tcp_connector" />
<xacro:transmission name = "transmission_tcp_connector_gripper_right"
joint_name = "tcp_connector_gripper_right"
actuator_name = "tcp_connector_gripper_right" />
<xacro:transmission name = "transmission_tcp_connector_gripper_left"
joint_name = "tcp_connector_gripper_left"
actuator_name = "tcp_connector_gripper_left" /> -->
<!-- creating gazebo plugin -->
<gazebo>
<plugin filename="libgz_ros2_control-system" name="gz_ros2_control::GazeboSimROS2ControlPlugin">
<parameters>$(find arm_simulation)/config/joint_controller.yaml</parameters>
<controller_manager_name>controller_manager</controller_manager_name>
</plugin>
</gazebo>
<ros2_control name="GazeboSystem" type="system">
<hardware>
<plugin>gz_ros2_control/GazeboSystem</plugin>
</hardware>
<joint name="base_link__link_1">
<command_interface name="position">
<param name="min">-3.14</param>
<param name="max">3.14</param>
</command_interface>
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
<joint name="link_1__link_2">
<command_interface name="position">
<param name="min">-3.14</param>
<param name="max">3.14</param>
</command_interface>
<state_interface name="position">
<param name="initial_value">0.0</param>
</state_interface>
<state_interface name="velocity">
<param name="initial_value">0.0</param>
</state_interface>
</joint>
</ros2_control>
My launch file-
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, Command
from launch_ros.actions import Node
import yaml
def generate_launch_description():
# sourcing the paths for the packages
arm_simulation_pkg_share = get_package_share_directory('arm_simulation')
gazebo_ros_pkg_share = get_package_share_directory('ros_gz_sim')
# sourcing the urdf and controller file
urdf_file_path = os.path.join(arm_simulation_pkg_share, 'urdf', 'arm.urdf')
controller_file_path = os.path.join(arm_simulation_pkg_share, 'config', 'joint_controller.yaml')
# loading the controllers from the yaml file
with open(controller_file_path, 'r') as file:
controller_params = yaml.safe_load(file)
# Spawning the robot at the given coordinates
x_space = DeclareLaunchArgument(
'x',
default_value='0.0',
)
y_space = DeclareLaunchArgument(
'y',
default_value='0.0',
)
z_space = DeclareLaunchArgument(
'z',
default_value='0.0',
)
# specifying the gazebo arguments
declare_sim_time = DeclareLaunchArgument(
'use_sim_time',
default_value='true',
)
declare_debug = DeclareLaunchArgument(
'debug',
default_value='false',
)
declare_gui = DeclareLaunchArgument(
'gui',
default_value='true',
)
declare_paused = DeclareLaunchArgument(
'paused',
default_value='true',
)
robot_description_content = Command([
'xacro ',
urdf_file_path
])
robot_description_param = {'robot_description': robot_description_content }
# 4. Launch Gazebo empty world
gazebo_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(ymal
os.path.join(
gazebo_ros_pkg_share,
'launch',
'gz_sim.launch.py'
)
),
launch_arguments={
'gz_args': os.path.join(gazebo_ros_pkg_share, 'worlds', 'empty.sdf'),
'use_sim_time': LaunchConfiguration('use_sim_time'),
'debug': LaunchConfiguration('debug'),
'gui': LaunchConfiguration('gui'),
# 'paused': LaunchConfiguration('paused')
}.items()
)
# 5 Loading the controller files
# Calling nodes
robot_state_publisher_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
parameters=[
robot_description_param,
{'use_sim_time': LaunchConfiguration('use_sim_time')}
],
)
spawn_robot_node = Node(
package='ros_gz_sim',
executable='create',
name='spawn_the_robot',
output='screen',
arguments=[
'-topic','robot_description',
'-entity', 'arm',
'-x', LaunchConfiguration('x'),
'-y', LaunchConfiguration('y'),
'-z', LaunchConfiguration('z'),
],
parameters=[
robot_description_param,
{'use_sim_time': LaunchConfiguration('use_sim_time')}
]
)
# controller_manager_node = Node(
# package = 'controller_manager',
# executable = 'ros2_control_node',
# output = 'both',
# parameters= [
# robot_description_param,
# controller_params,
# {'use_sim_time': LaunchConfiguration('use_sim_time')}
# ]
# )
# adding each joint nodes for individual controller
robot_controller_name = [
'joint_state_broadcaster',
'joint1_position_controller',
'joint2_position_controller'
]
spawner_nodes = [
Node(
package="controller_manager",
executable="spawner",
output="screen",
arguments=[
controllers,
'--controller-manager',
"/controller_manager",
]
) for controllers in robot_controller_name
]
return LaunchDescription([
x_space,
y_space,
z_space,
declare_sim_time,
declare_debug,
declare_gui,
declare_paused,
gazebo_launch,
robot_state_publisher_node,
spawn_robot_node,
# controller_manager_node,
*spawner_nodes
])
my .yaml file -
controller_manager:
ros__parameters:
update_rate: 100
use_sim_time: true
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster
joint1_position_controller:
type: forward_command_controller/ForwardCommandController
joint2_position_controller:
type: forward_command_controller/ForwardCommandController
joint_state_broadcaster:
ros__parameters:
joints:
- base_link__link_1
- link_1__link_2
joint1_position_controller:
ros__parameters:
joint:
- base_link__link_1
command_interfaces:
- position
state_interfaces:
- position
gains:
base_link__link_1:
p: 100.0
i: 0.0
d: 10.0
joint2_position_controller:
ros__parameters:
joint:
- link_1__link_2
command_interfaces:
- position
state_interfaces:
- position
gains:
link_1__link_2:
p: 100.0
i: 0.0
d: 10.0
I am using ROS2 Humble with gazebo Ignition along with Ubuntu 22.04. I am not able to activate my controller i tried everything. I made a custom UR5 robot..
i really appreciate the help.