Skip to content

Commit

Permalink
Support ros2 control (#1)
Browse files Browse the repository at this point in the history
* ROS2 and ros2_control

* Remove separate visualisation package

* Upgrade CMakeLists and package XML to be ament and colcon compatible
for ROS2

* Collapse rviz files into single view_robot file compatible with rviz2

* Rewrite launch file for visualisation

* Restructure urdf files to use a macro for greater potential
extensibility in future (for example, to support hardware versions)

* Add prefix and connected_to arguments

* Add ros2_control data

* Add port arguments

* Add control and monitoring ports

* Add default values for IP and ports

* Add limit parameters

* Add a velocity timeout parameter that controls the duration in seconds
that a velocity command remains active before the robot automatically
decelerates to a full stop.

* Update acceleration limit to reflect the mecadamic API to be in
percentage units of maximum

* Add velocity limit parameter as a percentage of maximum

* Fix parameter typo

* Remove := from port parameters

* Add missing name argument to launch file

* Add parameter to toggle ros2_control

* Parameter load_ros2_control enables or disables the inclusion
of ros2_control elements in the urdf generation

* meca_500_r3_macro.xacro renamed to just meca_500_r3.xacro
  • Loading branch information
eeberhard authored Jan 17, 2022
1 parent a4906c5 commit 5d283d8
Show file tree
Hide file tree
Showing 15 changed files with 670 additions and 577 deletions.
15 changes: 9 additions & 6 deletions mecademic_description/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(mecademic_description)

find_package(catkin REQUIRED COMPONENTS)
find_package(ament_cmake REQUIRED)

catkin_package()

include_directories(
${catkin_INCLUDE_DIRS}
install(
DIRECTORY launch meshes rviz urdf
DESTINATION share/${PROJECT_NAME}
)

ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

ament_package()
1 change: 1 addition & 0 deletions mecademic_description/launch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
4 changes: 0 additions & 4 deletions mecademic_description/launch/meca_500_r3.launch

This file was deleted.

90 changes: 90 additions & 0 deletions mecademic_description/launch/view_meca500_r3.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"name",
default_value="meca_500_r3",
description="Name of the mecademic robot",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"description_package",
default_value="mecademic_description",
description="Description package with robot URDF/XACRO files.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"description_file",
default_value="meca_500_r3.urdf.xacro",
description="URDF/XACRO description file with the robot.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"prefix",
default_value='""',
description="Prefix of the joint names, useful for \
multi-robot setup. If changed than also joint names in the controllers' configuration \
have to be updated.",
)
)

# Initialize Arguments
description_package = LaunchConfiguration("description_package")
description_file = LaunchConfiguration("description_file")
name = LaunchConfiguration("name")
prefix = LaunchConfiguration("prefix")

robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution([FindPackageShare(description_package), "urdf", description_file]),
" ",
"name:=",
name,
" ",
"prefix:=",
prefix,
]
)
robot_description = {"robot_description": robot_description_content}

rviz_config_file = PathJoinSubstitution(
[FindPackageShare(description_package), "rviz", "view_robot.rviz"]
)

joint_state_publisher_node = Node(
package="joint_state_publisher_gui",
executable="joint_state_publisher_gui",
)
robot_state_publisher_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file],
)

nodes_to_start = [
joint_state_publisher_node,
robot_state_publisher_node,
rviz_node,
]

return LaunchDescription(declared_arguments + nodes_to_start)
9 changes: 7 additions & 2 deletions mecademic_description/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mecademic_description</name>
<version>1.0.0</version>
<description>The mecademic_description package</description>
Expand All @@ -9,10 +10,14 @@

<license>MIT</license>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>urdf</exec_depend>
<exec_depend>xacro</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>rviz2</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
196 changes: 196 additions & 0 deletions mecademic_description/rviz/view_robot.rviz
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
Panels:
- Class: rviz_common/Displays
Help Height: 87
Name: Displays
Property Tree Widget:
Expanded:
- /RobotModel1/Description Topic1
Splitter Ratio: 0.5
Tree Height: 1096
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Goal Pose1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz_default_plugins/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Class: rviz_default_plugins/RobotModel
Collision Enabled: false
Description File: ""
Description Source: Topic
Description Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /robot_description
Enabled: true
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
base:
Alpha: 1
Show Axes: false
Show Trail: false
base_link:
Alpha: 1
Show Axes: false
Show Trail: false
base_link_inertia:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
flange:
Alpha: 1
Show Axes: false
Show Trail: false
forearm_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
shoulder_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
tool0:
Alpha: 1
Show Axes: false
Show Trail: false
upper_arm_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
wrist_1_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
wrist_2_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
wrist_3_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
Name: RobotModel
TF Prefix: ""
Update Interval: 0
Value: true
Visual Enabled: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: world
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/Interact
Hide Inactive Objects: true
- Class: rviz_default_plugins/MoveCamera
- Class: rviz_default_plugins/Select
- Class: rviz_default_plugins/FocusCamera
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /initialpose
- Class: rviz_default_plugins/SetGoal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /goal_pose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 3.493516445159912
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: -0.0457618348300457
Y: -0.07058511674404144
Z: 0.49734944105148315
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.15039828419685364
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 0.5353983640670776
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 1379
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd00000004000000000000016a000004f0fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000007901000003fb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c0061007900730100000048000004f00000010101000003fb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c000002610000000100000110000004f0fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730100000048000004f0000000db01000003fb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d0065010000000000000450000000000000000000000784000004f000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 2560
X: 0
Y: 30
Loading

0 comments on commit 5d283d8

Please sign in to comment.