diff --git a/ros_web_api_bellande_2d_computer_vision/README.md b/ros_web_api_bellande_2d_computer_vision/README.md index b78d1e8..35d8154 100644 --- a/ros_web_api_bellande_2d_computer_vision/README.md +++ b/ros_web_api_bellande_2d_computer_vision/README.md @@ -1,3 +1,3 @@ -# Bellande Search Path Web ROS/ROS2 API Intergration +# Bellande 2D Computer Vision Web ROS/ROS2 API Intergration -[Bellande Search Path](https://github.com/RonaldsonBellande/bellande_robots_step) +[Bellande 2D Computer Vision](https://github.com/RonaldsonBellande/bellande_2d_computer_vision) diff --git a/ros_web_api_bellande_3d_computer_vision/CMakeLists.txt b/ros_web_api_bellande_3d_computer_vision/CMakeLists.txt index fffcc76..7474e88 100644 --- a/ros_web_api_bellande_3d_computer_vision/CMakeLists.txt +++ b/ros_web_api_bellande_3d_computer_vision/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_3d_computer_vision_prediction.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_3d_computer_vision_api_2d.py DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + install(PROGRAMS src/bellande_3d_computer_vision_prediction.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_3d_computer_vision_api_2d.py DESTINATION lib/${PROJECT_NAME}) + install(PROGRAMS src/bellande_3d_computer_vision_prediction.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_3d_computer_vision/README.md b/ros_web_api_bellande_3d_computer_vision/README.md index b78d1e8..215b6c2 100644 --- a/ros_web_api_bellande_3d_computer_vision/README.md +++ b/ros_web_api_bellande_3d_computer_vision/README.md @@ -1,3 +1,3 @@ -# Bellande Search Path Web ROS/ROS2 API Intergration +# Bellande 3D Computer Vision Web ROS/ROS2 API Intergration -[Bellande Search Path](https://github.com/RonaldsonBellande/bellande_robots_step) +[Bellande 3D Computer Vision](https://github.com/RonaldsonBellande/bellande_3d_computer_vision) diff --git a/ros_web_api_bellande_3d_computer_vision/config/configs.json b/ros_web_api_bellande_3d_computer_vision/config/configs.json index bc40d6d..6009cbc 100644 --- a/ros_web_api_bellande_3d_computer_vision/config/configs.json +++ b/ros_web_api_bellande_3d_computer_vision/config/configs.json @@ -5,5 +5,6 @@ "object_detection": "/api/Bellande_3D_Computer_Vision/bellande_object_detection", "instance_segmentation": "/api/Bellande_3D_Computer_Vision/bellande_instance_segmentation", "sementic_segmentation": "/api/Bellande_3D_Computer_Vision/bellande_sementic_segmentation" - } + }, + "Bellande_Framework_Access_Key": "bellande_web_api_opensource" } diff --git a/ros_web_api_bellande_3d_computer_vision/launch/bellande_3d_computer_vision_prediction.launch.py b/ros_web_api_bellande_3d_computer_vision/launch/bellande_3d_computer_vision_prediction.launch.py new file mode 100644 index 0000000..cc090b0 --- /dev/null +++ b/ros_web_api_bellande_3d_computer_vision/launch/bellande_3d_computer_vision_prediction.launch.py @@ -0,0 +1,32 @@ +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", "bellande_3d_computer_vision_prediction", "bellande_step_api_2d.launch"] + args + + # Execute the launch command + subprocess.call(roslaunch_command) + + +def ros2_launch_description(): + pass + +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_3d_computer_vision/launch/ros1/bellande_3d_computer_vision_prediction.launch b/ros_web_api_bellande_3d_computer_vision/launch/ros1/bellande_3d_computer_vision_prediction.launch new file mode 100644 index 0000000..c8e56e0 --- /dev/null +++ b/ros_web_api_bellande_3d_computer_vision/launch/ros1/bellande_3d_computer_vision_prediction.launch @@ -0,0 +1,22 @@ + + + + + + diff --git a/ros_web_api_bellande_3d_computer_vision/script/build.sh b/ros_web_api_bellande_3d_computer_vision/script/build.sh new file mode 100644 index 0000000..199fe0e --- /dev/null +++ b/ros_web_api_bellande_3d_computer_vision/script/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Create and navigate to build directory +mkdir -p build && cd build + +# Build package +if [ $ROS_VERSION -eq 1 ]; then + cmake -DROS_VERSION=1 .. + make -j$(nproc) +else + cmake -DROS_VERSION=2 .. + make -j$(nproc) +fi + +# Source package setup file +source devel/setup.bash + +# Run rosdep +rosdep install --from-paths ../src --ignore-src -y + +# Return to package root directory +cd .. diff --git a/ros_web_api_bellande_3d_computer_vision/setup.py b/ros_web_api_bellande_3d_computer_vision/setup.py new file mode 100755 index 0000000..061f1bc --- /dev/null +++ b/ros_web_api_bellande_3d_computer_vision/setup.py @@ -0,0 +1,11 @@ +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_3d_computer_vision_prediction.py'], + packages=['ros_web_api_bellande_3d_computer_vision'], + package_dir={'': 'src'}, +) + +setup(**setup_args) diff --git a/ros_web_api_bellande_3d_computer_vision/src/bellande_3d_computer_vision_prediction.py b/ros_web_api_bellande_3d_computer_vision/src/bellande_3d_computer_vision_prediction.py new file mode 100755 index 0000000..63b33a5 --- /dev/null +++ b/ros_web_api_bellande_3d_computer_vision/src/bellande_3d_computer_vision_prediction.py @@ -0,0 +1,29 @@ +import json +import os +import requests + +def main(): + # Get the absolute path to the config file + config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json') + + # Check if the config file exists + if not os.path.exists(config_file_path): + print("Config file not found:", config_file_path) + return + + # Read configuration from config.json + with open(config_file_path, 'r') as config_file: + config = json.load(config_file) + url = config['url'] + endpoint_path = config['endpoint_path']["prediction"] + + + +if __name__ == '__main__': + ros_version = os.getenv("ROS_VERSION") + if ros_version == "1": + import rospy + elif ros_version == "2": + import rclpy + + main()