From e1bdebb248fa3463230de96197c620c605b9d762 Mon Sep 17 00:00:00 2001 From: RonaldsonBellande Date: Thu, 25 Jul 2024 23:03:02 -0400 Subject: [PATCH] latest pushes --- .../CMakeLists.txt | 13 +++- ..._adaptive_continuious_controller.launch.py | 61 ---------------- .../launch/bellande_controller.launch.py | 71 +++++++++++++++++++ ...ller.launch => bellande_controller.launch} | 24 +++---- .../setup.py | 19 ++++- ...s_controller.py => bellande_controller.py} | 0 6 files changed, 111 insertions(+), 77 deletions(-) delete mode 100644 ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_adaptive_continuious_controller.launch.py create mode 100644 ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_controller.launch.py rename ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/{bellande_adaptive_continuious_controller.launch => bellande_controller.launch} (55%) rename ros_web_api_bellande_adaptive_continuious_controller/src/{bellande_adaptive_continuious_controller.py => bellande_controller.py} (100%) diff --git a/ros_web_api_bellande_adaptive_continuious_controller/CMakeLists.txt b/ros_web_api_bellande_adaptive_continuious_controller/CMakeLists.txt index 131bb95..3f5c5d7 100644 --- a/ros_web_api_bellande_adaptive_continuious_controller/CMakeLists.txt +++ b/ros_web_api_bellande_adaptive_continuious_controller/CMakeLists.txt @@ -39,13 +39,22 @@ if($ENV{ROS_VERSION} EQUAL 1) ) endif() +# Install Python scripts for both ROS 1 +if($ENV{ROS_VERSION} EQUAL 1) + catkin_install_python( + PROGRAMS + src/bellande_controller.py + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + ) +endif() + # Install Python scripts, configuration files, and launch files if($ENV{ROS_VERSION} EQUAL "1") - install(PROGRAMS src/bellande_adaptive_continuious_controller_api_2d.py DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + install(PROGRAMS src/bellande_controller.py DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) install(DIRECTORY config/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config) install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch) elseif($ENV{ROS_VERSION} EQUAL "2") - install(PROGRAMS src/bellande_adaptive_continuious_controller_api_2d.py DESTINATION lib/${PROJECT_NAME}) + install(PROGRAMS src/bellande_controller.py DESTINATION lib/${PROJECT_NAME}) install(DIRECTORY config/ DESTINATION share/${PROJECT_NAME}/config) install(DIRECTORY launch/ DESTINATION share/${PROJECT_NAME}/launch) endif() diff --git a/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_adaptive_continuious_controller.launch.py b/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_adaptive_continuious_controller.launch.py deleted file mode 100644 index be7af43..0000000 --- a/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_adaptive_continuious_controller.launch.py +++ /dev/null @@ -1,61 +0,0 @@ -import os -import sys -import subprocess -from launch import LaunchDescription -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument -from launch.substitutions import LaunchConfiguration - - -def ros1_launch_description(): - # Get command-line arguments - args = sys.argv[1:] - - # Construct the ROS 1 launch commandi - roslaunch_command = ["roslaunch", "ros_web_api_bellande_step", "bellande_step_api_2d.launch"] + args - - # Execute the launch command - subprocess.call(roslaunch_command) - - -def ros2_launch_description(): - # Declare launch arguments - x1_arg = DeclareLaunchArgument('x1') - y1_arg = DeclareLaunchArgument('y1') - x2_arg = DeclareLaunchArgument('x2') - y2_arg = DeclareLaunchArgument('y2') - limit_arg = DeclareLaunchArgument('limit') - - # Create a list to hold all nodes to be launched - nodes_to_launch = [] - - # ROS2 specific configurations - ros_launch_arguments = [ - x1_arg, y1_arg, x2_arg, y2_arg, limit_arg, - ] - nodes_to_launch.append(Node( - package='ros_web_api_bellande_step', - executable='bellande_step_api_2d.py', - name='bellande_step_api_2d_node', - output='screen', - parameters=[ - {'x1': LaunchConfiguration('x1')}, - {'y1': LaunchConfiguration('y1')}, - {'x2': LaunchConfiguration('x2')}, - {'y2': LaunchConfiguration('y2')}, - {'limit': LaunchConfiguration('limit')}, - ], - )) - - # Return the LaunchDescription containing all nodes and arguments - return LaunchDescription(ros_launch_arguments + nodes_to_launch) - -if __name__ == "__main__": - ros_version = os.getenv("ROS_VERSION") - if ros_version == "1": - ros1_launch_description() - elif ros_version == "2": - ros2_launch_description() - else: - print("Unsupported ROS version. Please set the ROS_VERSION environment variable to '1' for ROS 1 or '2' for ROS 2.") - sys.exit(1) diff --git a/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_controller.launch.py b/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_controller.launch.py new file mode 100644 index 0000000..647b04c --- /dev/null +++ b/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_controller.launch.py @@ -0,0 +1,71 @@ +# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import sys +import subprocess +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration + +def ros1_launch_description(): + # Get command-line arguments + args = sys.argv[1:] + # Construct the ROS 1 launch command + roslaunch_command = ["roslaunch", "ros_web_api_bellande_adaptive_continuious_controller", "bellande_controller.launch"] + args + # Execute the launch command + subprocess.call(roslaunch_command) + +def ros2_launch_description(): + # Declare launch arguments + setpoint_arg = DeclareLaunchArgument('setpoint') + kp_arg = DeclareLaunchArgument('kp') + ki_arg = DeclareLaunchArgument('ki') + kd_arg = DeclareLaunchArgument('kd') + + # Create a list to hold all nodes to be launched + nodes_to_launch = [] + + # ROS2 specific configurations + ros_launch_arguments = [ + setpoint_arg, kp_arg, ki_arg, kd_arg, + ] + + nodes_to_launch.append(Node( + package='ros_web_api_bellande_adaptive_continuious_controller', + executable='bellande_controller.py', + name='bellande_controller_node', + output='screen', + parameters=[ + {'setpoint': LaunchConfiguration('setpoint')}, + {'kp': LaunchConfiguration('kp')}, + {'ki': LaunchConfiguration('ki')}, + {'kd': LaunchConfiguration('kd')}, + ], + )) + + # Return the LaunchDescription containing all nodes and arguments + return LaunchDescription(ros_launch_arguments + nodes_to_launch) + +if __name__ == "__main__": + ros_version = os.getenv("ROS_VERSION") + if ros_version == "1": + ros1_launch_description() + elif ros_version == "2": + ros2_launch_description() + else: + print("Unsupported ROS version. Please set the ROS_VERSION environment variable to '1' for ROS 1 or '2' for ROS 2.") + sys.exit(1) diff --git a/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_adaptive_continuious_controller.launch b/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_controller.launch similarity index 55% rename from ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_adaptive_continuious_controller.launch rename to ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_controller.launch index 15edced..359b763 100644 --- a/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_adaptive_continuious_controller.launch +++ b/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_controller.launch @@ -15,18 +15,18 @@ License for the specific language governing permissions and limitations under the License. --> - - - - - + + + + + - - - - - - + + + + + + diff --git a/ros_web_api_bellande_adaptive_continuious_controller/setup.py b/ros_web_api_bellande_adaptive_continuious_controller/setup.py index 5ec6985..b46d54f 100755 --- a/ros_web_api_bellande_adaptive_continuious_controller/setup.py +++ b/ros_web_api_bellande_adaptive_continuious_controller/setup.py @@ -1,10 +1,25 @@ +# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + from distutils.core import setup from catkin_pkg.python_setup import generate_distutils_setup # fetch values from package.xml setup_args = generate_distutils_setup( - scripts=['src/bellande_step_api_2d.py'], - packages=['ros_web_api_bellande_step'], + scripts=['src/bellande_controller.py'], + packages=['ros_web_api_bellande_adaptive_continuious_controller'], package_dir={'': 'src'}, ) diff --git a/ros_web_api_bellande_adaptive_continuious_controller/src/bellande_adaptive_continuious_controller.py b/ros_web_api_bellande_adaptive_continuious_controller/src/bellande_controller.py similarity index 100% rename from ros_web_api_bellande_adaptive_continuious_controller/src/bellande_adaptive_continuious_controller.py rename to ros_web_api_bellande_adaptive_continuious_controller/src/bellande_controller.py