diff --git a/.gitignore b/.gitignore index 1377554..73587f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +**/**/compile_commands.json 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 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