From 6f06846665c1b6bfe5aec6903d674fc61810665e Mon Sep 17 00:00:00 2001 From: RonaldsonBellande Date: Mon, 6 May 2024 03:08:01 -0400 Subject: [PATCH] latest pushes --- .../CMakeLists.txt | 51 ++++++++++++++++++ .../README.md | 3 ++ .../package.xml | 53 +++++++++++++++++++ .../launch/bellande_step_api_2d.launch.py | 4 -- .../launch/ros1/bellande_step_api_2d.launch | 16 ++++++ .../src/bellande_step_api_2d.py | 31 +++++------ 6 files changed, 135 insertions(+), 23 deletions(-) create mode 100644 ros_web_api_bellande_speech_detection/CMakeLists.txt create mode 100644 ros_web_api_bellande_speech_detection/README.md create mode 100644 ros_web_api_bellande_speech_detection/package.xml create mode 100644 ros_web_api_bellande_step/launch/ros1/bellande_step_api_2d.launch diff --git a/ros_web_api_bellande_speech_detection/CMakeLists.txt b/ros_web_api_bellande_speech_detection/CMakeLists.txt new file mode 100644 index 0000000..8a55503 --- /dev/null +++ b/ros_web_api_bellande_speech_detection/CMakeLists.txt @@ -0,0 +1,51 @@ +# 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 . + +cmake_minimum_required(VERSION 3.8) +project(ros_web_api_bellande_speech_detection) + +# Find ROS +if($ENV{ROS_VERSION} EQUAL 1) + find_package(catkin REQUIRED COMPONENTS + roscpp + rospy + ) +else() + find_package(ament_cmake REQUIRED COMPONENTS + rclcpp + rclpy + ) +endif() + +if($ENV{ROS_VERSION} EQUAL 1) + catkin_package( + INCLUDE_DIRS + LIBRARIES ${PROJECT_NAME} + CATKIN_DEPENDS + roscpp + rospy + ) +endif() + +# Install Python scripts, configuration files, and launch files +if($ENV{ROS_VERSION} EQUAL "1") + install(PROGRAMS src/bellande_2d_computer_vision_api_2d.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_2d_computer_vision_api_2d.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_speech_detection/README.md b/ros_web_api_bellande_speech_detection/README.md new file mode 100644 index 0000000..b78d1e8 --- /dev/null +++ b/ros_web_api_bellande_speech_detection/README.md @@ -0,0 +1,3 @@ +# Bellande Search Path Web ROS/ROS2 API Intergration + +[Bellande Search Path](https://github.com/RonaldsonBellande/bellande_robots_step) diff --git a/ros_web_api_bellande_speech_detection/package.xml b/ros_web_api_bellande_speech_detection/package.xml new file mode 100644 index 0000000..9c038c5 --- /dev/null +++ b/ros_web_api_bellande_speech_detection/package.xml @@ -0,0 +1,53 @@ + + + + ros_web_api_bellande_speech_detection + 0.0.1 + Bellande ROS/ROS2 package with a JSON config file for making HTTP requests + Ronaldson Bellande + Ronaldson Bellande + Apache License 2.0 + + + catkin + + roscpp + rospy + + roscpp + rospy + + roscpp + rospy + + + ament_cmake + + rclcpp + rclpy + + rclcpp + rclpy + + rclcpp + rclpy + + + + + diff --git a/ros_web_api_bellande_step/launch/bellande_step_api_2d.launch.py b/ros_web_api_bellande_step/launch/bellande_step_api_2d.launch.py index 3b3bdcc..c235410 100644 --- a/ros_web_api_bellande_step/launch/bellande_step_api_2d.launch.py +++ b/ros_web_api_bellande_step/launch/bellande_step_api_2d.launch.py @@ -1,10 +1,6 @@ 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(): diff --git a/ros_web_api_bellande_step/launch/ros1/bellande_step_api_2d.launch b/ros_web_api_bellande_step/launch/ros1/bellande_step_api_2d.launch new file mode 100644 index 0000000..1bc2afe --- /dev/null +++ b/ros_web_api_bellande_step/launch/ros1/bellande_step_api_2d.launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/ros_web_api_bellande_step/src/bellande_step_api_2d.py b/ros_web_api_bellande_step/src/bellande_step_api_2d.py index 91ee859..1d091a1 100755 --- a/ros_web_api_bellande_step/src/bellande_step_api_2d.py +++ b/ros_web_api_bellande_step/src/bellande_step_api_2d.py @@ -1,7 +1,6 @@ import json import os import requests -import sys def main(): # Get the absolute path to the config file @@ -18,25 +17,13 @@ def main(): url = config['url'] endpoint_path = config['endpoint_path'] - # Get the parameters from the launch file - x1_str = os.getenv('x1') - y1_str = os.getenv('y1') - x2_str = os.getenv('x2') - y2_str = os.getenv('y2') - limit_str = os.getenv('limit') + # Get the parameters from the ROS parameter server + x1 = rospy.get_param('x1') + y1 = rospy.get_param('y1') + x2 = rospy.get_param('x2') + y2 = rospy.get_param('y2') + limit = rospy.get_param('limit') - # Check if any of the environment variables are not set - if any(v is None for v in [x1_str, y1_str, x2_str, y2_str, limit_str]): - print("One or more required environment variables are not set.") - return - - # Convert the parameters to float or int - x1 = float(x1_str) - y1 = float(y1_str) - x2 = float(x2_str) - y2 = float(y2_str) - limit = int(limit_str) - # JSON payload payload = { "node0": {"x": x1, "y": y1}, @@ -64,4 +51,10 @@ def main(): print("Error:", e) if __name__ == '__main__': + ros_version = os.getenv("ROS_VERSION") + if ros_version == "1": + import rospy + elif ros_version == "2": + rclpy + main()