diff --git a/foxy_bringup/config/controllers.yaml b/foxy_bringup/config/controllers.yaml new file mode 100644 index 0000000..b8226d9 --- /dev/null +++ b/foxy_bringup/config/controllers.yaml @@ -0,0 +1,59 @@ +/**/controller_manager: + ros__parameters: + update_rate: 100 # Hz + + joint_state_broadcaster: + type: joint_state_broadcaster/JointStateBroadcaster + + diff_drive_base_controller: + type: diff_drive_controller/DiffDriveController + +/**/diff_drive_base_controller: + ros__parameters: + left_wheel_names: ["left_wheel_joint"] + right_wheel_names: ["right_wheel_joint"] + + wheel_separation: 0.45 + #wheels_per_side: 1 # actually 2, but both are controlled by 1 signal + wheel_radius: 0.05 + + wheel_separation_multiplier: 1.0 + left_wheel_radius_multiplier: 1.0 + right_wheel_radius_multiplier: 1.0 + + publish_rate: 50.0 + odom_frame_id: odom + base_frame_id: base_link + pose_covariance_diagonal : [0.001, 0.001, 0.0, 0.0, 0.0, 0.01] + twist_covariance_diagonal: [0.001, 0.0, 0.0, 0.0, 0.0, 0.01] + + + open_loop: false + enable_odom_tf: true + + cmd_vel_timeout: 0.5 + #publish_limited_velocity: true + use_stamped_vel: true + #velocity_rolling_window_size: 10 + + # Velocity and acceleration limits + + # Whenever a min_* is unspecified, default to -max_* + linear.x.has_velocity_limits: true + linear.x.has_acceleration_limits: true + linear.x.has_jerk_limits: false + linear.x.max_velocity: 1.0 + linear.x.min_velocity: -1.0 + linear.x.max_acceleration: 1.0 + linear.x.max_jerk: 0.0 + linear.x.min_jerk: 0.0 + + angular.z.has_velocity_limits: true + angular.z.has_acceleration_limits: true + angular.z.has_jerk_limits: false + angular.z.max_velocity: 1.0 + angular.z.min_velocity: -1.0 + angular.z.max_acceleration: 1.0 + angular.z.min_acceleration: -1.0 + angular.z.max_jerk: 0.0 + angular.z.min_jerk: 0.0 diff --git a/foxy_bringup/config/default.rviz b/foxy_bringup/config/default.rviz new file mode 100644 index 0000000..c599eaf --- /dev/null +++ b/foxy_bringup/config/default.rviz @@ -0,0 +1,220 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /RobotModel1 + Splitter Ratio: 0.5 + Tree Height: 555 + - 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 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: "" +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: + 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: /foxy/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_footprint: + Alpha: 1 + Show Axes: false + Show Trail: false + caster_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + foxy/base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + base_footprint: + Value: true + caster_wheel: + Value: true + foxy/base_link: + Value: true + foxy/odom: + Value: true + left_wheel: + Value: true + right_wheel: + Value: true + Marker Scale: 0.699999988079071 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: false + Tree: + foxy/base_link: + base_footprint: + {} + caster_wheel: + {} + left_wheel: + {} + right_wheel: + {} + foxy/odom: + {} + Update Interval: 0 + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: foxy/odom + 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 + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + 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: 1.6701574325561523 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0 + Y: 0 + Z: 0 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.22539816796779633 + Target Frame: + Value: Orbit (rviz) + Yaw: 1.030397891998291 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 846 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd000000040000000000000156000002b4fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000002b4000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002b4fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000002b4000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000005450000003efc0100000002fb0000000800540069006d00650100000000000005450000025300fffffffb0000000800540069006d00650100000000000004500000000000000000000002d4000002b400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1349 + X: 304 + Y: 2 diff --git a/foxy_bringup/foxy_bringup/__init__.py b/foxy_bringup/foxy_bringup/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/foxy_bringup/launch/robot.launch.py b/foxy_bringup/launch/robot.launch.py new file mode 100644 index 0000000..6437f27 --- /dev/null +++ b/foxy_bringup/launch/robot.launch.py @@ -0,0 +1,137 @@ +import os +import xacro +from launch.conditions import IfCondition, LaunchConfigurationEquals +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch import LaunchDescription, LaunchDescriptionEntity +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription, OpaqueFunction +from launch_ros.substitutions import FindPackageShare +from launch_ros.actions import Node, PushRosNamespace + +def launch_args(context) -> list[LaunchDescriptionEntity]: + + declared_args = [] + + declared_args.append(DeclareLaunchArgument( + "robot_name", + description="Robot name." + )) + + declared_args.append(DeclareLaunchArgument( + "system", + default_value="gz", + description="Choose system to start, e.g. robot or gz for Gazebo", + choices=['gz', 'robot'] + )) + + declared_args.append(DeclareLaunchArgument( + "rviz_start", + default_value="true", + description="Launch Rviz" + )) + + declared_args.append(DeclareLaunchArgument( + "rviz_config", + default_value=PathJoinSubstitution([FindPackageShare("foxy_bringup"), "config", "default.rviz"]), + description="Configuration file for launching rviz." + )) + + return declared_args + + +def launch_setup(context) -> list[LaunchDescriptionEntity]: + + use_sim_time = {"use_sim_time": True if LaunchConfiguration("system").perform(context) != 'robot' else False } + + robot_desc_content = xacro.process_file( + PathJoinSubstitution([FindPackageShare("foxy_description"), "urdf", "foxy.urdf.xacro"]).perform(context), + mappings={ + "robot_name": LaunchConfiguration("robot_name").perform(context), + "system": LaunchConfiguration("system").perform(context), + "distro": os.getenv("ROS_DISTRO") + } + ).toxml() + + robot_state_publisher_node = Node( + package="robot_state_publisher", + executable="robot_state_publisher", + name="robot_state_publisher", + output="both", + parameters=[ + {"robot_description": robot_desc_content}, + use_sim_time + ] + ) + + controllers = GroupAction( + actions=[ + Node( + package="controller_manager", + executable="spawner", + arguments=["joint_state_broadcaster", "diff_drive_base_controller"], + output='screen' + ), + ] + ) + + gz = GroupAction( + actions=[ + IncludeLaunchDescription( + PathJoinSubstitution([ + FindPackageShare("ros_gz_sim"), + "launch", + "gz_sim.launch.py" + ]), + launch_arguments={ + "gz_args": ["-r ", "empty.sdf"], # `-r` start running simulation immediately + 'on_exit_shutdown': 'True' + }.items() + ), + Node( + package="ros_gz_sim", + executable="create", + arguments=[ + "-name", LaunchConfiguration("robot_name"), + "-topic", "robot_description", + "-x", "0", + "-y", "0", + "-z", "0.3" + ], + output='screen' + ), + ], + condition=LaunchConfigurationEquals("system", "gz") + ) + + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock'], + output='screen' + ) + + rviz2 = Node( + package='rviz2', + executable='rviz2', + name='rviz2', + arguments=['-d', LaunchConfiguration("rviz_config")], + output='screen', + condition=IfCondition(LaunchConfiguration("rviz_start")) + ) + + return [ + PushRosNamespace(LaunchConfiguration("robot_name")), + robot_state_publisher_node, + controllers, + gz, + bridge, + rviz2 + ] + + +def generate_launch_description() -> LaunchDescription: + + ld = LaunchDescription() + ld.add_action(OpaqueFunction(function=launch_args)) + ld.add_action(OpaqueFunction(function=launch_setup)) + + return ld diff --git a/foxy_bringup/package.xml b/foxy_bringup/package.xml new file mode 100644 index 0000000..b12c32a --- /dev/null +++ b/foxy_bringup/package.xml @@ -0,0 +1,20 @@ + + + + foxy_bringup + 0.0.0 + TODO: Package description + harley + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + gz_ros2_control + + + ament_python + + diff --git a/foxy_bringup/resource/foxy_bringup b/foxy_bringup/resource/foxy_bringup new file mode 100644 index 0000000..e69de29 diff --git a/foxy_bringup/setup.cfg b/foxy_bringup/setup.cfg new file mode 100644 index 0000000..d7dbd75 --- /dev/null +++ b/foxy_bringup/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/foxy_bringup +[install] +install_scripts=$base/lib/foxy_bringup diff --git a/foxy_bringup/setup.py b/foxy_bringup/setup.py new file mode 100644 index 0000000..9f09203 --- /dev/null +++ b/foxy_bringup/setup.py @@ -0,0 +1,28 @@ +import glob +from setuptools import find_packages, setup + +package_name = 'foxy_bringup' + +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']), + ('share/' + package_name + '/launch', glob.glob('launch/*')), + ('share/' + package_name + '/config', glob.glob('config/*')), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='harley', + maintainer_email='harley.lara@outlook.com', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + ], + }, +) diff --git a/foxy_bringup/test/test_copyright.py b/foxy_bringup/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/foxy_bringup/test/test_copyright.py @@ -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' diff --git a/foxy_bringup/test/test_flake8.py b/foxy_bringup/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/foxy_bringup/test/test_flake8.py @@ -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) diff --git a/foxy_bringup/test/test_pep257.py b/foxy_bringup/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/foxy_bringup/test/test_pep257.py @@ -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' diff --git a/foxy_description/urdf/base.xacro b/foxy_description/urdf/base.xacro index b788f08..02dbfb8 100644 --- a/foxy_description/urdf/base.xacro +++ b/foxy_description/urdf/base.xacro @@ -1,4 +1,3 @@ - @@ -19,12 +18,18 @@ + - + + + + + + @@ -35,22 +40,44 @@ + - + + + + + + + + + + + + - + + + + + + + + + + + @@ -61,20 +88,31 @@ + + + + + + + + + - + - + + - + - + + diff --git a/foxy_description/urdf/foxy.urdf.xacro b/foxy_description/urdf/foxy.urdf.xacro index 0d9ac03..912b67d 100644 --- a/foxy_description/urdf/foxy.urdf.xacro +++ b/foxy_description/urdf/foxy.urdf.xacro @@ -1,15 +1,51 @@ - + + - + + + + + + + ign_ros2_control/IgnitionSystem + + + + -1 + 1 + + + + + + + -1 + 1 + + + + + + + + + + ${namespace} + + $(find foxy_bringup)/config/controllers.yaml + + + +