diff --git a/ros_web_api_bellande_adaptive_alternate_path_creation/launch/bellande_adaptive_alternate_path_creation.launch.py b/ros_web_api_bellande_adaptive_alternate_path_creation/launch/bellande_adaptive_alternate_path_creation.launch.py
new file mode 100644
index 0000000..be7af43
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_alternate_path_creation/launch/bellande_adaptive_alternate_path_creation.launch.py
@@ -0,0 +1,61 @@
+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_alternate_path_creation/launch/ros1/bellande_adaptive_alternate_path_creation.launch b/ros_web_api_bellande_adaptive_alternate_path_creation/launch/ros1/bellande_adaptive_alternate_path_creation.launch
new file mode 100644
index 0000000..15edced
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_alternate_path_creation/launch/ros1/bellande_adaptive_alternate_path_creation.launch
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ros_web_api_bellande_adaptive_alternate_path_creation/script/build.sh b/ros_web_api_bellande_adaptive_alternate_path_creation/script/build.sh
new file mode 100644
index 0000000..78e4cf0
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_alternate_path_creation/script/build.sh
@@ -0,0 +1,29 @@
+#!/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 ..
+
+# Run ROS launch file
+if [ $ROS_VERSION -eq 1 ]; then
+ roslaunch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+else
+ ros2 launch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+fi
diff --git a/ros_web_api_bellande_adaptive_alternate_path_creation/setup.py b/ros_web_api_bellande_adaptive_alternate_path_creation/setup.py
new file mode 100755
index 0000000..5ec6985
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_alternate_path_creation/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_step_api_2d.py'],
+ packages=['ros_web_api_bellande_step'],
+ package_dir={'': 'src'},
+)
+
+setup(**setup_args)
diff --git a/ros_web_api_bellande_adaptive_alternate_path_creation/src/bellande_adaptive_alternate_path_creation.py b/ros_web_api_bellande_adaptive_alternate_path_creation/src/bellande_adaptive_alternate_path_creation.py
new file mode 100755
index 0000000..118edce
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_alternate_path_creation/src/bellande_adaptive_alternate_path_creation.py
@@ -0,0 +1,61 @@
+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"]
+
+ # Get the parameters from the ROS parameter server
+ x1 = rospy.get_param('x1', 0)
+ y1 = rospy.get_param('y1', 0)
+ x2 = rospy.get_param('x2', 0)
+ y2 = rospy.get_param('y2', 0)
+ limit = rospy.get_param('limit', 3)
+
+ # JSON payload
+ payload = {
+ "node0": {"x": x1, "y": y1},
+ "node1": {"x": x2, "y": y2}
+ }
+
+ # Headers
+ headers = {
+ 'accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+
+
+ # Make POST request
+ try:
+ response = requests.post(
+ url + endpoint_path + '?limit=' + str(limit),
+ json=payload,
+ headers=headers
+ )
+ response.raise_for_status() # Raise an error for unsuccessful responses
+ data = response.json()
+ print("Next Step:", data['next_step'])
+
+ except requests.exceptions.RequestException as e:
+ print("Error:", e)
+
+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_adaptive_continuious_controller/config/configs.json b/ros_web_api_bellande_adaptive_continuious_controller/config/configs.json
index fa4e23d..8fbca40 100644
--- a/ros_web_api_bellande_adaptive_continuious_controller/config/configs.json
+++ b/ros_web_api_bellande_adaptive_continuious_controller/config/configs.json
@@ -1,14 +1,22 @@
{
+ "license": [
+ "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 .",
+ "GNU General Public License v3.0 or later"
+ ],
"url": "https://bellanderoboticssensorsresearchinnovationcenter-kot42qxp.b4a.run",
"endpoint_path": {
- "2d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_2d",
- "3d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_3d",
- "4d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_4d",
- "5d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_5d",
- "6d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_6d",
- "7d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_7d",
- "8d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_8d",
- "9d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_9d",
- "10d": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller_10d"
+ "bellande_controller": "/api/Bellande_Adaptive_Continuious_Controller/bellande_adaptive_continuious_controller"
}
}
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
new file mode 100644
index 0000000..be7af43
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_continuious_controller/launch/bellande_adaptive_continuious_controller.launch.py
@@ -0,0 +1,61 @@
+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/ros1/bellande_adaptive_continuious_controller.launch b/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_adaptive_continuious_controller.launch
new file mode 100644
index 0000000..15edced
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_continuious_controller/launch/ros1/bellande_adaptive_continuious_controller.launch
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ros_web_api_bellande_adaptive_continuious_controller/setup.py b/ros_web_api_bellande_adaptive_continuious_controller/setup.py
new file mode 100755
index 0000000..5ec6985
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_continuious_controller/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_step_api_2d.py'],
+ packages=['ros_web_api_bellande_step'],
+ package_dir={'': 'src'},
+)
+
+setup(**setup_args)
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_adaptive_continuious_controller.py
new file mode 100755
index 0000000..cd5e10f
--- /dev/null
+++ b/ros_web_api_bellande_adaptive_continuious_controller/src/bellande_adaptive_continuious_controller.py
@@ -0,0 +1,100 @@
+# 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 json
+import os
+import requests
+from std_msgs.msg import Float64
+
+def bellande_controller(setpoint, current_value, kp, ki, kd):
+ payload = {
+ "setpoint": setpoint,
+ "current_value": current_value,
+ "kp": kp,
+ "ki": ki,
+ "kd": kd
+ }
+ headers = {
+ "Authorization": f"Bearer {api_access_key}"
+ }
+ response = requests.post(api_url, json=payload, headers=headers)
+ if response.status_code == 200:
+ result = response.json()
+ return result['control_output']
+ else:
+ print(f"Error: {response.status_code} - {response.text}")
+ return None
+
+def control_callback(msg):
+ setpoint = rospy.get_param('setpoint', 0)
+ kp = rospy.get_param('kp', 1.0)
+ ki = rospy.get_param('ki', 0.1)
+ kd = rospy.get_param('kd', 0.05)
+
+ control_output = bellande_controller(setpoint, msg.data, kp, ki, kd)
+ if control_output is not None:
+ output_msg = Float64()
+ output_msg.data = control_output
+ pub.publish(output_msg)
+
+def main():
+ global api_url, api_access_key, pub
+ config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json')
+
+ if not os.path.exists(config_file_path):
+ print("Config file not found:", config_file_path)
+ return
+
+ with open(config_file_path, 'r') as config_file:
+ config = json.load(config_file)
+ url = config['url']
+ endpoint_path = config['endpoint_path']["bellande_controller"]
+ api_access_key = config["Bellande_Framework_Access_Key"]
+
+ # Initialize ROS node
+ if ros_version == "1":
+ rospy.init_node('bellande_controller_node', anonymous=True)
+ pub = rospy.Publisher('control_output', Float64, queue_size=10)
+ sub = rospy.Subscriber('current_value', Float64, control_callback)
+ elif ros_version == "2":
+ rclpy.init()
+ node = rclpy.create_node('bellande_controller_node')
+ pub = node.create_publisher(Float64, 'control_output', 10)
+ sub = node.create_subscription(Float64, 'current_value', control_callback, 10)
+
+ api_url = f"{url}{endpoint_path}"
+
+ try:
+ print("BellandeController node is running. Ctrl+C to exit.")
+ if ros_version == "1":
+ rospy.spin()
+ elif ros_version == "2":
+ rclpy.spin(node)
+ except KeyboardInterrupt:
+ print("Shutting down BellandeController node.")
+ except Exception as e:
+ print(f"An error occurred: {str(e)}")
+ finally:
+ if ros_version == "2":
+ node.destroy_node()
+ rclpy.shutdown()
+
+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_extremum_optimization/launch/bellande_extremum_optimization.launch.py b/ros_web_api_bellande_extremum_optimization/launch/bellande_extremum_optimization.launch.py
new file mode 100644
index 0000000..be7af43
--- /dev/null
+++ b/ros_web_api_bellande_extremum_optimization/launch/bellande_extremum_optimization.launch.py
@@ -0,0 +1,61 @@
+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_extremum_optimization/launch/ros1/bellande_extremum_optimization.launch b/ros_web_api_bellande_extremum_optimization/launch/ros1/bellande_extremum_optimization.launch
new file mode 100644
index 0000000..15edced
--- /dev/null
+++ b/ros_web_api_bellande_extremum_optimization/launch/ros1/bellande_extremum_optimization.launch
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ros_web_api_bellande_extremum_optimization/script/build.sh b/ros_web_api_bellande_extremum_optimization/script/build.sh
new file mode 100644
index 0000000..78e4cf0
--- /dev/null
+++ b/ros_web_api_bellande_extremum_optimization/script/build.sh
@@ -0,0 +1,29 @@
+#!/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 ..
+
+# Run ROS launch file
+if [ $ROS_VERSION -eq 1 ]; then
+ roslaunch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+else
+ ros2 launch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+fi
diff --git a/ros_web_api_bellande_extremum_optimization/setup.py b/ros_web_api_bellande_extremum_optimization/setup.py
new file mode 100755
index 0000000..5ec6985
--- /dev/null
+++ b/ros_web_api_bellande_extremum_optimization/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_step_api_2d.py'],
+ packages=['ros_web_api_bellande_step'],
+ package_dir={'': 'src'},
+)
+
+setup(**setup_args)
diff --git a/ros_web_api_bellande_extremum_optimization/src/bellande_extremum_optimization.py b/ros_web_api_bellande_extremum_optimization/src/bellande_extremum_optimization.py
new file mode 100755
index 0000000..118edce
--- /dev/null
+++ b/ros_web_api_bellande_extremum_optimization/src/bellande_extremum_optimization.py
@@ -0,0 +1,61 @@
+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"]
+
+ # Get the parameters from the ROS parameter server
+ x1 = rospy.get_param('x1', 0)
+ y1 = rospy.get_param('y1', 0)
+ x2 = rospy.get_param('x2', 0)
+ y2 = rospy.get_param('y2', 0)
+ limit = rospy.get_param('limit', 3)
+
+ # JSON payload
+ payload = {
+ "node0": {"x": x1, "y": y1},
+ "node1": {"x": x2, "y": y2}
+ }
+
+ # Headers
+ headers = {
+ 'accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+
+
+ # Make POST request
+ try:
+ response = requests.post(
+ url + endpoint_path + '?limit=' + str(limit),
+ json=payload,
+ headers=headers
+ )
+ response.raise_for_status() # Raise an error for unsuccessful responses
+ data = response.json()
+ print("Next Step:", data['next_step'])
+
+ except requests.exceptions.RequestException as e:
+ print("Error:", e)
+
+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_motion_probabilistic/launch/bellande_motion_probabilistic.launch.py b/ros_web_api_bellande_motion_probabilistic/launch/bellande_motion_probabilistic.launch.py
new file mode 100644
index 0000000..be7af43
--- /dev/null
+++ b/ros_web_api_bellande_motion_probabilistic/launch/bellande_motion_probabilistic.launch.py
@@ -0,0 +1,61 @@
+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_motion_probabilistic/launch/ros1/bellande_motion_probabilistic.launch b/ros_web_api_bellande_motion_probabilistic/launch/ros1/bellande_motion_probabilistic.launch
new file mode 100644
index 0000000..15edced
--- /dev/null
+++ b/ros_web_api_bellande_motion_probabilistic/launch/ros1/bellande_motion_probabilistic.launch
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ros_web_api_bellande_motion_probabilistic/script/build.sh b/ros_web_api_bellande_motion_probabilistic/script/build.sh
new file mode 100644
index 0000000..78e4cf0
--- /dev/null
+++ b/ros_web_api_bellande_motion_probabilistic/script/build.sh
@@ -0,0 +1,29 @@
+#!/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 ..
+
+# Run ROS launch file
+if [ $ROS_VERSION -eq 1 ]; then
+ roslaunch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+else
+ ros2 launch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+fi
diff --git a/ros_web_api_bellande_motion_probabilistic/setup.py b/ros_web_api_bellande_motion_probabilistic/setup.py
new file mode 100755
index 0000000..5ec6985
--- /dev/null
+++ b/ros_web_api_bellande_motion_probabilistic/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_step_api_2d.py'],
+ packages=['ros_web_api_bellande_step'],
+ package_dir={'': 'src'},
+)
+
+setup(**setup_args)
diff --git a/ros_web_api_bellande_motion_probabilistic/src/bellande_motion_probabilistic.py b/ros_web_api_bellande_motion_probabilistic/src/bellande_motion_probabilistic.py
new file mode 100755
index 0000000..118edce
--- /dev/null
+++ b/ros_web_api_bellande_motion_probabilistic/src/bellande_motion_probabilistic.py
@@ -0,0 +1,61 @@
+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"]
+
+ # Get the parameters from the ROS parameter server
+ x1 = rospy.get_param('x1', 0)
+ y1 = rospy.get_param('y1', 0)
+ x2 = rospy.get_param('x2', 0)
+ y2 = rospy.get_param('y2', 0)
+ limit = rospy.get_param('limit', 3)
+
+ # JSON payload
+ payload = {
+ "node0": {"x": x1, "y": y1},
+ "node1": {"x": x2, "y": y2}
+ }
+
+ # Headers
+ headers = {
+ 'accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+
+
+ # Make POST request
+ try:
+ response = requests.post(
+ url + endpoint_path + '?limit=' + str(limit),
+ json=payload,
+ headers=headers
+ )
+ response.raise_for_status() # Raise an error for unsuccessful responses
+ data = response.json()
+ print("Next Step:", data['next_step'])
+
+ except requests.exceptions.RequestException as e:
+ print("Error:", e)
+
+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_search_path/launch/bellande_search_path.launch.py b/ros_web_api_bellande_search_path/launch/bellande_search_path.launch.py
new file mode 100644
index 0000000..be7af43
--- /dev/null
+++ b/ros_web_api_bellande_search_path/launch/bellande_search_path.launch.py
@@ -0,0 +1,61 @@
+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_search_path/launch/ros1/bellande_search_path.launch b/ros_web_api_bellande_search_path/launch/ros1/bellande_search_path.launch
new file mode 100644
index 0000000..15edced
--- /dev/null
+++ b/ros_web_api_bellande_search_path/launch/ros1/bellande_search_path.launch
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ros_web_api_bellande_search_path/script/build.sh b/ros_web_api_bellande_search_path/script/build.sh
new file mode 100644
index 0000000..78e4cf0
--- /dev/null
+++ b/ros_web_api_bellande_search_path/script/build.sh
@@ -0,0 +1,29 @@
+#!/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 ..
+
+# Run ROS launch file
+if [ $ROS_VERSION -eq 1 ]; then
+ roslaunch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+else
+ ros2 launch ros_web_api_bellande_step bellande_step_api_2d_launch.launch.py x1:=0 y1:=0 x2:=5 y2:=5 limit:=3
+fi
diff --git a/ros_web_api_bellande_search_path/setup.py b/ros_web_api_bellande_search_path/setup.py
new file mode 100755
index 0000000..5ec6985
--- /dev/null
+++ b/ros_web_api_bellande_search_path/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_step_api_2d.py'],
+ packages=['ros_web_api_bellande_step'],
+ package_dir={'': 'src'},
+)
+
+setup(**setup_args)
diff --git a/ros_web_api_bellande_search_path/src/bellande_search_path.py b/ros_web_api_bellande_search_path/src/bellande_search_path.py
new file mode 100755
index 0000000..118edce
--- /dev/null
+++ b/ros_web_api_bellande_search_path/src/bellande_search_path.py
@@ -0,0 +1,61 @@
+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"]
+
+ # Get the parameters from the ROS parameter server
+ x1 = rospy.get_param('x1', 0)
+ y1 = rospy.get_param('y1', 0)
+ x2 = rospy.get_param('x2', 0)
+ y2 = rospy.get_param('y2', 0)
+ limit = rospy.get_param('limit', 3)
+
+ # JSON payload
+ payload = {
+ "node0": {"x": x1, "y": y1},
+ "node1": {"x": x2, "y": y2}
+ }
+
+ # Headers
+ headers = {
+ 'accept': 'application/json',
+ 'Content-Type': 'application/json'
+ }
+
+
+ # Make POST request
+ try:
+ response = requests.post(
+ url + endpoint_path + '?limit=' + str(limit),
+ json=payload,
+ headers=headers
+ )
+ response.raise_for_status() # Raise an error for unsuccessful responses
+ data = response.json()
+ print("Next Step:", data['next_step'])
+
+ except requests.exceptions.RequestException as e:
+ print("Error:", e)
+
+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_speech_detection/src/bellande_speech_detection.py b/ros_web_api_bellande_speech_detection/src/bellande_speech_detection.py
index 3389fee..1e269d5 100755
--- a/ros_web_api_bellande_speech_detection/src/bellande_speech_detection.py
+++ b/ros_web_api_bellande_speech_detection/src/bellande_speech_detection.py
@@ -16,53 +16,78 @@
import json
import os
import requests
+from std_msgs.msg import String
-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']["detection"]
-
- # Get the parameters from the ROS parameter server
- audio_data = rospy.get_param('audio_data', '')
- sample_rate = rospy.get_param('sample_rate', 16000)
- language = rospy.get_param('language', 'en-US')
-
- # JSON payload
+def speech_detection(audio_data, sample_rate, language):
payload = {
"audio_data": audio_data,
"sample_rate": sample_rate,
"language": language
}
-
- # Headers
headers = {
+ "Authorization": f"Bearer {api_access_key}",
'accept': 'application/json',
'Content-Type': 'application/json'
}
+ response = requests.post(api_url, json=payload, headers=headers)
+ if response.status_code == 200:
+ result = response.json()
+ return result['detected_speech']
+ else:
+ print(f"Error: {response.status_code} - {response.text}")
+ return None
- # Make POST request
- try:
- response = requests.post(
- url + endpoint_path,
- json=payload,
- headers=headers
- )
- response.raise_for_status() # Raise an error for unsuccessful responses
- data = response.json()
- print("Detected Speech:", data['detected_speech'])
+def audio_callback(msg):
+ sample_rate = rospy.get_param('sample_rate', 16000)
+ language = rospy.get_param('language', 'en-US')
- except requests.exceptions.RequestException as e:
- print("Error:", e)
+ detected_speech = speech_detection(msg.data, sample_rate, language)
+ if detected_speech is not None:
+ output_msg = String()
+ output_msg.data = detected_speech
+ pub.publish(output_msg)
+
+def main():
+ global api_url, api_access_key, pub
+ config_file_path = os.path.join(os.path.dirname(__file__), '../config/configs.json')
+
+ if not os.path.exists(config_file_path):
+ print("Config file not found:", config_file_path)
+ return
+
+ with open(config_file_path, 'r') as config_file:
+ config = json.load(config_file)
+ url = config['url']
+ endpoint_path = config['endpoint_path']["speech_detection"]
+ api_access_key = config["Bellande_Framework_Access_Key"]
+
+ # Initialize ROS node
+ if ros_version == "1":
+ rospy.init_node('speech_detection_node', anonymous=True)
+ pub = rospy.Publisher('detected_speech', String, queue_size=10)
+ sub = rospy.Subscriber('audio_data', String, audio_callback)
+ elif ros_version == "2":
+ rclpy.init()
+ node = rclpy.create_node('speech_detection_node')
+ pub = node.create_publisher(String, 'detected_speech', 10)
+ sub = node.create_subscription(String, 'audio_data', audio_callback, 10)
+
+ api_url = f"{url}{endpoint_path}"
+
+ try:
+ print("Speech detection node is running. Ctrl+C to exit.")
+ if ros_version == "1":
+ rospy.spin()
+ elif ros_version == "2":
+ rclpy.spin(node)
+ except KeyboardInterrupt:
+ print("Shutting down speech detection node.")
+ except Exception as e:
+ print(f"An error occurred: {str(e)}")
+ finally:
+ if ros_version == "2":
+ node.destroy_node()
+ rclpy.shutdown()
if __name__ == '__main__':
ros_version = os.getenv("ROS_VERSION")