diff --git a/ros_web_api_bellande_2d_computer_vision/config/configs.json b/ros_web_api_bellande_2d_computer_vision/config/configs.json index 7d8704d..f220ffc 100644 --- a/ros_web_api_bellande_2d_computer_vision/config/configs.json +++ b/ros_web_api_bellande_2d_computer_vision/config/configs.json @@ -6,5 +6,5 @@ "instance_segmentation": "/api/Bellande_2D_Computer_Vision/bellande_instance_segmentation", "sementic_segmentation": "/api/Bellande_2D_Computer_Vision/bellande_sementic_segmentation" }, - "access_key": "bellande_web_api_opensource" + "Bellande_Framework_Access_Key": "bellande_web_api_opensource" } diff --git a/ros_web_api_bellande_2d_computer_vision/launch/bellande_2d_computer_vision_prediction.launch.py b/ros_web_api_bellande_2d_computer_vision/launch/bellande_2d_computer_vision_prediction.launch.py new file mode 100644 index 0000000..a87c258 --- /dev/null +++ b/ros_web_api_bellande_2d_computer_vision/launch/bellande_2d_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_2d_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_2d_computer_vision/launch/ros1/bellande_2d_computer_vision_prediction.launch b/ros_web_api_bellande_2d_computer_vision/launch/ros1/bellande_2d_computer_vision_prediction.launch new file mode 100644 index 0000000..5e5a7d2 --- /dev/null +++ b/ros_web_api_bellande_2d_computer_vision/launch/ros1/bellande_2d_computer_vision_prediction.launch @@ -0,0 +1,22 @@ + + + + + + diff --git a/ros_web_api_bellande_2d_computer_vision/script/build.sh b/ros_web_api_bellande_2d_computer_vision/script/build.sh new file mode 100644 index 0000000..199fe0e --- /dev/null +++ b/ros_web_api_bellande_2d_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_2d_computer_vision/setup.py b/ros_web_api_bellande_2d_computer_vision/setup.py new file mode 100755 index 0000000..767ef92 --- /dev/null +++ b/ros_web_api_bellande_2d_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_2d_computer_vision_prediction.py'], + packages=['ros_web_api_bellande_2d_computer_vision'], + package_dir={'': 'src'}, +) + +setup(**setup_args) diff --git a/ros_web_api_bellande_2d_computer_vision/src/bellande_2d_computer_vision_prediction.py b/ros_web_api_bellande_2d_computer_vision/src/bellande_2d_computer_vision_prediction.py new file mode 100755 index 0000000..f2d448a --- /dev/null +++ b/ros_web_api_bellande_2d_computer_vision/src/bellande_2d_computer_vision_prediction.py @@ -0,0 +1,28 @@ +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']["2d"] + + +if __name__ == '__main__': + ros_version = os.getenv("ROS_VERSION") + if ros_version == "1": + import rospy + elif ros_version == "2": + import rclpy + + main() diff --git a/ros_web_api_bellande_step/config/configs.json b/ros_web_api_bellande_step/config/configs.json index 2c40b05..bd0f1b9 100644 --- a/ros_web_api_bellande_step/config/configs.json +++ b/ros_web_api_bellande_step/config/configs.json @@ -11,5 +11,5 @@ "9d": "/api/Bellande_Step/bellande_step_9d", "10d": "/api/Bellande_Step/bellande_step_10d" }, - "access_key": "bellande_web_api_opensource" + "Bellande_Framework_Access_Key": "bellande_web_api_opensource" }