Fixed ur_robotiq_control.launch.py error

added ur_robotiq_servo
This commit is contained in:
Niko Feith 2024-04-02 14:55:40 +02:00
parent 503587c227
commit ab2278c0c8
13 changed files with 220 additions and 55 deletions

View File

@ -6,7 +6,9 @@ RUN apt-get update && apt-get install -y \
python3-colcon-common-extensions python3-pip \ python3-colcon-common-extensions python3-pip \
ros-humble-xacro \ ros-humble-xacro \
ros-humble-hardware-interface \ ros-humble-hardware-interface \
ros-humble-controller-interface ros-humble-controller-interface \
ros-humble-joy \
ros-humble-teleop-twist-joy
COPY requirements.txt ./ COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
@ -32,4 +34,5 @@ RUN echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/ros/humble/bin" ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/ros/humble/bin"
# Source the workspace # Source the workspace
RUN echo "source install/setup.bash" >> /root/.bashrc
CMD ["/bin/bash"] CMD ["/bin/bash"]

View File

@ -32,13 +32,41 @@ To download this repository and all of its included submodules, follow these ste
cd UR-Robotiq cd UR-Robotiq
``` ```
* When using the "ur_robotiq.urdf" file first run
```bash
cd /ros2_ws/src/ur_robotiq_description/urdf
ros2 run xacro xacro ur_robotiq.urdf.xacro > ur_robotiq.urdf
```
* Run the following command to start the Docker Compose: * Run the following command to start the Docker Compose:
```bash ```bash
docker-compose up -d docker compose up -d
```
* Give X11 permission to accept the stream of the container window:
```bash
xhost +
```
* Get the name of the container:
```bash
docker ps
```
* Access the terminal of the docker container
```bash
docker exec -it <name of docker container> /bin/bash
``` ```
## Working with UR + Robotiq
In general you need to start up the UR Robotiq Controller,
here the *robot_ip* has to be defined and if you want to start up the real robot or use fake hardware and if you want to launch rviz!
```bash
ros2 launch ur_robotiq_description ur_robotiq_control.launch.py robot_ip:=aaa.bbb.ccc.ddd use_fake_hardware:=<true/false(default)> launch_rviz:=<true/false(default)>
```
In addition you can start up the moveit interface:
```bash
ros2 launch ur_robotiq_moveit_config ur_robotiq_moveit.launch.py use_fake_hardware:=<true/false(default)>
```
### use_fake_hardware:=true
Terminal 1.:
```bash
ros2 launch ur_robotiq_description ur_robotiq_control.launch.py robot_ip:=aaa.bbb.ccc.ddd use_fake_hardware:=true launch_rviz:=false
```
Terminal 2.:
```bash
ros2 launch ur_robotiq_moveit_config ur_robotiq_moveit.launch.py use_fake_hardware:=true
```

View File

@ -13,6 +13,7 @@ services:
- DISPLAY=$DISPLAY - DISPLAY=$DISPLAY
devices: devices:
- /dev/dri:/dev/dri - /dev/dri:/dev/dri
- /dev/input:/dev/input
networks: networks:
ros_network: ros_network:

View File

@ -191,7 +191,11 @@ def launch_setup(context, *args, **kwargs):
control_node = Node( control_node = Node(
package="controller_manager", package="controller_manager",
executable="ros2_control_node", executable="ros2_control_node",
parameters=[robot_description, update_rate_config_file, initial_joint_controllers], parameters=[
robot_description,
update_rate_config_file,
ParameterFile(initial_joint_controllers, allow_substs=True),
],
output="screen", output="screen",
condition=IfCondition(use_fake_hardware), condition=IfCondition(use_fake_hardware),
) )
@ -199,7 +203,11 @@ def launch_setup(context, *args, **kwargs):
ur_control_node = Node( ur_control_node = Node(
package="ur_robot_driver", package="ur_robot_driver",
executable="ur_ros2_control_node", executable="ur_ros2_control_node",
parameters=[robot_description, update_rate_config_file, initial_joint_controllers], parameters=[
robot_description,
update_rate_config_file,
ParameterFile(initial_joint_controllers, allow_substs=True),
],
output="screen", output="screen",
condition=UnlessCondition(use_fake_hardware), condition=UnlessCondition(use_fake_hardware),
) )
@ -282,55 +290,58 @@ def launch_setup(context, *args, **kwargs):
arguments=["-d", rviz_config_file], arguments=["-d", rviz_config_file],
) )
joint_state_broadcaster_spawner = Node( # Spawn controllers
package="controller_manager", def controller_spawner(name, active=True):
executable="spawner", inactive_flags = ["--inactive"] if not active else []
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], return Node(
)
io_and_status_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["io_and_status_controller", "-c", "/controller_manager"],
)
speed_scaling_state_broadcaster_spawner = Node(
package="controller_manager", package="controller_manager",
executable="spawner", executable="spawner",
arguments=[ arguments=[
name,
"--controller-manager",
"/controller_manager",
"--controller-manager-timeout",
controller_spawner_timeout,
]
+ inactive_flags,
)
controller_spawner_names = [
"joint_state_broadcaster",
"io_and_status_controller",
"speed_scaling_state_broadcaster", "speed_scaling_state_broadcaster",
"--controller-manager",
"/controller_manager",
],
)
force_torque_sensor_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=[
"force_torque_sensor_broadcaster", "force_torque_sensor_broadcaster",
"--controller-manager", ]
"/controller_manager", controller_spawner_inactive_names = ["forward_position_controller"]
],
)
forward_position_controller_spawner_stopped = Node( controller_spawners = [controller_spawner(name) for name in controller_spawner_names] + [
package="controller_manager", controller_spawner(name, active=False) for name in controller_spawner_inactive_names
executable="spawner", ]
arguments=["forward_position_controller", "-c", "/controller_manager", "--stopped"],
)
# There may be other controllers of the joints, but this is the initially-started one # There may be other controllers of the joints, but this is the initially-started one
initial_joint_controller_spawner_started = Node( initial_joint_controller_spawner_started = Node(
package="controller_manager", package="controller_manager",
executable="spawner", executable="spawner",
arguments=[initial_joint_controller, "-c", "/controller_manager"], arguments=[
initial_joint_controller,
"-c",
"/controller_manager",
"--controller-manager-timeout",
controller_spawner_timeout,
],
condition=IfCondition(activate_joint_controller), condition=IfCondition(activate_joint_controller),
) )
initial_joint_controller_spawner_stopped = Node( initial_joint_controller_spawner_stopped = Node(
package="controller_manager", package="controller_manager",
executable="spawner", executable="spawner",
arguments=[initial_joint_controller, "-c", "/controller_manager", "--stopped"], arguments=[
initial_joint_controller,
"-c",
"/controller_manager",
"--controller-manager-timeout",
controller_spawner_timeout,
"--inactive",
],
condition=UnlessCondition(activate_joint_controller), condition=UnlessCondition(activate_joint_controller),
) )
@ -344,14 +355,9 @@ def launch_setup(context, *args, **kwargs):
controller_stopper_node, controller_stopper_node,
robot_state_publisher_node, robot_state_publisher_node,
rviz_node, rviz_node,
joint_state_broadcaster_spawner,
io_and_status_controller_spawner,
speed_scaling_state_broadcaster_spawner,
force_torque_sensor_broadcaster_spawner,
forward_position_controller_spawner_stopped,
initial_joint_controller_spawner_stopped, initial_joint_controller_spawner_stopped,
initial_joint_controller_spawner_started, initial_joint_controller_spawner_started,
] ] + controller_spawners
return nodes_to_start return nodes_to_start

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ur_robotiq_servo</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="nikolaus.feith@unileoben.ac.at">niko</maintainer>
<license>TODO: License declaration</license>
<depend>rclpy</depend>
<depend>sensor_msgs</depend>
<depend>geometry_msgs</depend>
<depend>std_msgs</depend>
<depend>joy</depend>
<depend>moveit_servo</depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<export>
<build_type>ament_python</build_type>
</export>
</package>

View File

@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/ur_robotiq_servo
[install]
install_scripts=$base/lib/ur_robotiq_servo

View File

@ -0,0 +1,25 @@
from setuptools import find_packages, setup
package_name = 'ur_robotiq_servo'
setup(
name=package_name,
version='0.0.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='niko',
maintainer_email='nikolaus.feith@unileoben.ac.at',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
],
},
)

View File

@ -0,0 +1,25 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ament_copyright.main import main
import pytest
# Remove the `skip` decorator once the source file(s) have a copyright header
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'

View File

@ -0,0 +1,25 @@
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ament_flake8.main import main_with_errors
import pytest
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8():
rc, errors = main_with_errors(argv=[])
assert rc == 0, \
'Found %d code style errors / warnings:\n' % len(errors) + \
'\n'.join(errors)

View File

@ -0,0 +1,23 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ament_pep257.main import main
import pytest
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'