stefanscherzinger / cartesian_controllers_universal_robots

An easy-to-start configuration for cartesian_controllers on Universal Robots
BSD 3-Clause "New" or "Revised" License
20 stars 9 forks source link

Changes in package #3

Closed student-0103 closed 9 months ago

student-0103 commented 9 months ago

Hi :) I am trying to use cartesian controllers on the UR5e.

What I did:

When launching, i get the error of an invalid parameter: "robot_ip" and no robot spawns in Rviz.

Any more steps I have to do to correctly launch the robot.launch.py?

pietrzakmat commented 9 months ago

Hi @Daan0103, how did you set the default robot ip? It shall be in the following line of robot.launch.py: https://github.com/stefanscherzinger/cartesian_controllers_universal_robots/blob/a6b95437c8a11480600c609d4b0c9260581fe214/launch/robot.launch.py#L21 If so just make sure the IP address is typed correctly.

If you have such error like invalid parameter means either something is misspelled or you miss sourcing or required packages. Did you source your workspace? source install/setup.sh Do you have all the packages ur_description, ur_client_library and ur_robot_drive installed in your system? They are required in setup.urdf.xacro.

pietrzakmat commented 9 months ago

Please post full command(s) you are calling (after opening fresh cli window) and log content.

student-0103 commented 9 months ago

Ok I will! I think it was a small mistake from me indeed, did a clean build and changed in every file the robot_ip again, and now the error is solved. But a new one occurs when launching:

      $ ros2 launch cartesian_controllers_universal_robots robot.launch.py 
[INFO] [launch]: All log files can be found below /home/daan/.ros/log/2024-01-08-16-20-25-179954-daan-1203-62942
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): executed command failed. Command: /opt/ros/humble/bin/xacro /home/daan/ros2_ws/install/cartesian_controllers_universal_robots/share/cartesian_controllers_universal_robots/urdf/setup.urdf.xacro robot_ip:=192.168.1.102
Captured stderr output: error: 'NoneType' object is not subscriptable 
when evaluating expression 'sec_kinematics['shoulder']['x']'
when instantiating macro: read_model_data (/home/daan/ros2_ws/install/ur_description/share/ur_description/urdf/inc/ur_common.xacro)
instantiated from: ur_robot (/home/daan/ros2_ws/install/ur_description/share/ur_description/urdf/ur_macro.xacro)
in file: /home/daan/ros2_ws/install/cartesian_controllers_universal_robots/share/cartesian_controllers_universal_robots/urdf/setup.urdf.xacro

Looks like a problem in ur_description, but i don't think there is actually the error/mistake?

student-0103 commented 9 months ago

After I open fresh window:

$ cd ros2_ws
$ colcon build
$ source install/setup.bash
$ ros2 launch cartesian_controllers_universal_robots robot.launch.py 
pietrzakmat commented 9 months ago

It looks like a macro ur_robot variable is somewhere missing or is incorrect in xacro files...
Therefore it can't load config for model.

Did you change <xacro:ur_robot name="ur10e" to in: https://github.com/stefanscherzinger/cartesian_controllers_universal_robots/blob/a6b95437c8a11480600c609d4b0c9260581fe214/urdf/setup.urdf.xacro#L16

Additionally for clean install, run rm -rf install/ before next build.

student-0103 commented 9 months ago

Yeah, my setup.urdf.xacro is as follows:

<?xml version="1.0"?>

<robot name="ur5e" xmlns:xacro="http://ros.org/wiki/xacro">

        <xacro:include filename="$(find ur_description)/urdf/ur_macro.xacro" />
        <xacro:arg name="robot_ip" default="192.168.1.102" />

        <link name="world" />

        <joint name="world_joint" type="fixed">
                <origin xyz="0 0 0" rpy="0 0 0" />
                <parent link="world" />
                <child link="base_link" />
        </joint>

        <xacro:ur_robot name="ur5e"
                tf_prefix=""
                parent="world"
                robot_ip="$(arg robot_ip)"
                joint_limits_parameters_file="$(find ur_description)/config/ur5e/joint_limits.yaml"
                kinematics_parameters_file="$(find cartesian_controllers_universal_robots)/config/test_calibration.yaml"
                physical_parameters_file="$(find ur_description)/config/ur5e/physical_parameters.yaml"
                visual_parameters_file="$(find ur_description)/config/ur5e/visual_parameters.yaml"
                script_filename="$(find ur_client_library)/resources/external_control.urscript"
                input_recipe_filename="$(find ur_robot_driver)/resources/rtde_input_recipe.txt"
                output_recipe_filename="$(find ur_robot_driver)/resources/rtde_output_recipe.txt"
                use_fake_hardware="false">
          <origin xyz="0 0.0 0.0" rpy="0 0 0" />
        </xacro:ur_robot>

</robot>

I did the clean install, but the same error as before ( 'Captured stderr output: error: 'NoneType' object is not subscriptable' ).

pietrzakmat commented 9 months ago

Based on the error you posted it looks the problem is with missing parameter ur_macro.xacro which is a part of Universal_Robots_ROS2_Description repo: https://github.com/UniversalRobots/Universal_Robots_ROS2_Description/blob/29e90d5095fdf4af99eba3c3eae153d7d5d769c0/urdf/inc/ur_common.xacro#L96 This is the ur_description package. Can you confirm that ur_description works by itself in your sourced terminal: ros2 launch ur_description view_ur.launch.py ur_type:=ur5e It shall open rviz wih loaded model of ur5e.

student-0103 commented 9 months ago

Yes, i can confirm. It opens a rviz model of the ur5e, with a Joint state publisher.

rqt as follows: Screenshot from 2024-01-09 11-02-58

When I connect my PC to robot (ethernet cable) and $ ros2 launch cartesian_controllers_universal_robots robot.launch.py RViz starts up (empty world without robot), and the known error occurs. This is it's rqt: Screenshot from 2024-01-09 11-08-53

So, looks like problem with launching, description package?

pietrzakmat commented 9 months ago

Yes, at some point the parameters for description package are not provided correctly. I have one more idea, a possible reason. Can you check for a test the default calibration, meaning in setup.urdf.xacro use default calibration.yaml: kinematics_parameters_file="$(find cartesian_controllers_universal_robots)/config/test_calibration.yaml" to kinematics_parameters_file="$(find ur_description)/config/ur5e/default_kinematics.yaml"

student-0103 commented 9 months ago

That was the problem, with this change Rviz launches correctly and the ur5e spawns correcly (same as in real-life).

Now I can deactivate scaled_joint_trajectory_controller, and activate cartesian_motion_controller. So, i only have to write my own program for these controllers?

pietrzakmat commented 9 months ago

I am glad it helped. If it solved the initial problem, please close the issue.

So now if you want to control the robot:

  1. In joint space then keep scaled_joint_trajectory_controller on and publish from your own program to trajectory_msgs::msg::JointTrajectory topic.
  2. In Cartesian space you activate i.e. cartesian_motion_controller and publish geometry_msgs::msg::PoseStamped topic. You also have to deactivate scaled_joint_trajectory_controller then.
student-0103 commented 9 months ago

Thank you for your help and fast responses, I appreciate it! I will close the issue :)