From 156aea12c70fff57e1f2d97cb1ea66ccb2dbc98d Mon Sep 17 00:00:00 2001 From: Valerio Magnago Date: Tue, 28 Mar 2023 00:41:19 +0200 Subject: [PATCH 1/3] Add compile_commands.json to .gitignore. Sometimes compile_commands.json files are copied inside the package to help linters. Ignore these files because they are user specific and not useful to track. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1377554..73587f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +**/**/compile_commands.json From 270ae0dc26232b3773ff1e59773abd6412529ba5 Mon Sep 17 00:00:00 2001 From: Valerio Magnago Date: Tue, 28 Mar 2023 00:43:38 +0200 Subject: [PATCH 2/3] Refactor vesc driver launch. This commit refactor the vesc driver launch taking the nav2 bringup launch as reference. As part of the refactoring an argument to set the node logging level was added. --- vesc_driver/launch/vesc_driver_node.launch.py | 43 ++++++++++++++----- .../params/{vesc_config.yaml => config.yaml} | 0 2 files changed, 32 insertions(+), 11 deletions(-) rename vesc_driver/params/{vesc_config.yaml => config.yaml} (100%) diff --git a/vesc_driver/launch/vesc_driver_node.launch.py b/vesc_driver/launch/vesc_driver_node.launch.py index b9777e7..46eff46 100644 --- a/vesc_driver/launch/vesc_driver_node.launch.py +++ b/vesc_driver/launch/vesc_driver_node.launch.py @@ -37,22 +37,43 @@ def generate_launch_description(): - vesc_config = os.path.join( + # Get default config file. + config = os.path.join( get_package_share_directory('vesc_driver'), 'params', - 'vesc_config.yaml' + 'config.yaml' ) - return LaunchDescription([ - DeclareLaunchArgument( + + # Create the launch configuration variables + config_yaml = LaunchConfiguration("config") + log_level = LaunchConfiguration('log_level') + + declare_log_level_cmd = DeclareLaunchArgument( + 'log_level', default_value='info', + description='log level') + + declare_config_yaml_cmd = DeclareLaunchArgument( name="config", - default_value=vesc_config, - description="VESC yaml configuration file.", - ), - Node( + default_value=config, + description="Vesc driver configuration file.", + ) + + start_vesc_driver_cmd = Node( package='vesc_driver', executable='vesc_driver_node', name='vesc_driver_node', - parameters=[LaunchConfiguration("config")] - ), + parameters=[config_yaml], + arguments=['--ros-args', '--log-level', log_level], + ) + + # Create the launch description and populate + ld = LaunchDescription() + + # Declare the launch options + ld.add_action(declare_config_yaml_cmd) + ld.add_action(declare_log_level_cmd) + + # Add the action to launch the node + ld.add_action(start_vesc_driver_cmd) - ]) + return ld diff --git a/vesc_driver/params/vesc_config.yaml b/vesc_driver/params/config.yaml similarity index 100% rename from vesc_driver/params/vesc_config.yaml rename to vesc_driver/params/config.yaml From 49981614ab9cfb580850762d2938cca164562997 Mon Sep 17 00:00:00 2001 From: Valerio Magnago Date: Tue, 28 Mar 2023 00:53:32 +0200 Subject: [PATCH 3/3] Uniform vesc ackermann launch file to vesc driver. --- .../launch/ackermann_to_vesc_node.launch.py | 80 +++++++++++++++++++ .../launch/ackermann_to_vesc_node.launch.xml | 14 ---- .../launch/vesc_to_odom_node.launch.py | 80 +++++++++++++++++++ .../launch/vesc_to_odom_node.launch.xml | 19 ----- .../params/ackermann_to_vesc_config.yaml | 6 ++ .../params/vesc_to_odom_config.yaml | 11 +++ 6 files changed, 177 insertions(+), 33 deletions(-) create mode 100644 vesc_ackermann/launch/ackermann_to_vesc_node.launch.py delete mode 100644 vesc_ackermann/launch/ackermann_to_vesc_node.launch.xml create mode 100644 vesc_ackermann/launch/vesc_to_odom_node.launch.py delete mode 100644 vesc_ackermann/launch/vesc_to_odom_node.launch.xml create mode 100644 vesc_ackermann/params/ackermann_to_vesc_config.yaml create mode 100644 vesc_ackermann/params/vesc_to_odom_config.yaml diff --git a/vesc_ackermann/launch/ackermann_to_vesc_node.launch.py b/vesc_ackermann/launch/ackermann_to_vesc_node.launch.py new file mode 100644 index 0000000..fe56dd1 --- /dev/null +++ b/vesc_ackermann/launch/ackermann_to_vesc_node.launch.py @@ -0,0 +1,80 @@ +# Copyright 2020 F1TENTH Foundation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the {copyright_holder} nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import os + +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + + # Get default config file. + vesc_ackermann_config = os.path.join( + get_package_share_directory('vesc_ackermann'), + 'params', + 'ackermann_to_vesc_config.yaml' + ) + + # Create the launch configuration variables + config_yaml = LaunchConfiguration("config") + log_level = LaunchConfiguration('log_level') + + declare_log_level_cmd = DeclareLaunchArgument( + 'log_level', default_value='info', + description='log level') + + declare_config_yaml_cmd = DeclareLaunchArgument( + name="config", + default_value=vesc_ackermann_config, + description="Ackermann to vesc configuration file.", + ) + + # Specify the actions + start_vesc_ackermann_cmd = Node( + package='vesc_ackermann', + executable='ackermann_to_vesc_node', + name='ackermann_to_vesc_node', + parameters=[config_yaml], + arguments=['--ros-args', '--log-level', log_level], + ) + + # Create the launch description and populate + ld = LaunchDescription() + + # Declare the launch options + ld.add_action(declare_config_yaml_cmd) + ld.add_action(declare_log_level_cmd) + + # Add the action to launch the node + ld.add_action(start_vesc_ackermann_cmd) + + return ld diff --git a/vesc_ackermann/launch/ackermann_to_vesc_node.launch.xml b/vesc_ackermann/launch/ackermann_to_vesc_node.launch.xml deleted file mode 100644 index 4cbf7b7..0000000 --- a/vesc_ackermann/launch/ackermann_to_vesc_node.launch.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/vesc_ackermann/launch/vesc_to_odom_node.launch.py b/vesc_ackermann/launch/vesc_to_odom_node.launch.py new file mode 100644 index 0000000..17fa408 --- /dev/null +++ b/vesc_ackermann/launch/vesc_to_odom_node.launch.py @@ -0,0 +1,80 @@ +# Copyright 2020 F1TENTH Foundation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of the {copyright_holder} nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import os + +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + + # Get default config file. + vesc_ackermann_config = os.path.join( + get_package_share_directory('vesc_ackermann'), + 'params', + 'vesc_to_odom_config.yaml' + ) + + # Create the launch configuration variables + config_yaml = LaunchConfiguration("config") + log_level = LaunchConfiguration('log_level') + + declare_log_level_cmd = DeclareLaunchArgument( + 'log_level', default_value='info', + description='log level') + + declare_config_yaml_cmd = DeclareLaunchArgument( + name="config", + default_value=vesc_ackermann_config, + description="Vesc to odom configuration file.", + ) + + # Specify the actions + start_vesc_to_odom_cmd = Node( + package='vesc_ackermann', + executable='vesc_to_odom_node', + name='vesc_to_odom_node', + parameters=[config_yaml], + arguments=['--ros-args', '--log-level', log_level], + ) + + # Create the launch description and populate + ld = LaunchDescription() + + # Declare the launch options + ld.add_action(declare_config_yaml_cmd) + ld.add_action(declare_log_level_cmd) + + # Add the action to launch the node + ld.add_action(start_vesc_to_odom_cmd) + + return ld diff --git a/vesc_ackermann/launch/vesc_to_odom_node.launch.xml b/vesc_ackermann/launch/vesc_to_odom_node.launch.xml deleted file mode 100644 index 712d443..0000000 --- a/vesc_ackermann/launch/vesc_to_odom_node.launch.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/vesc_ackermann/params/ackermann_to_vesc_config.yaml b/vesc_ackermann/params/ackermann_to_vesc_config.yaml new file mode 100644 index 0000000..1759878 --- /dev/null +++ b/vesc_ackermann/params/ackermann_to_vesc_config.yaml @@ -0,0 +1,6 @@ +/**: + ros__parameters: + speed_to_erpm_gain: 4614.0 # ERPM/(m/s) + speed_to_erpm_offset: 0.0 # ERPM + steering_angle_to_servo_gain: -1.2135 # ppm/rad + steering_angle_to_servo_offset: 0.5304 # ppm diff --git a/vesc_ackermann/params/vesc_to_odom_config.yaml b/vesc_ackermann/params/vesc_to_odom_config.yaml new file mode 100644 index 0000000..b2c3689 --- /dev/null +++ b/vesc_ackermann/params/vesc_to_odom_config.yaml @@ -0,0 +1,11 @@ +/**: + ros__parameters: + speed_to_erpm_gain: 1.0 # ERPM/(m/s) + speed_to_erpm_offset: 0.0 # ERPM + steering_angle_to_servo_gain: 1.0 # ppm/rad + steering_angle_to_servo_offset: 0.2 # ppm + odom_frame: "odom" + base_frame: "base_link" + use_servo_cmd_to_calc_angular_velocity: True + wheelbase: 0.2 # m + publish_tf: True