diff --git a/.gitignore b/.gitignore index 3e54b1f..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +0,0 @@ -publish.sh -tests -setup.py -dist diff --git a/Package/python/publish.sh b/Package/python/publish.sh new file mode 100755 index 0000000..48934a9 --- /dev/null +++ b/Package/python/publish.sh @@ -0,0 +1,2 @@ +python setup.py sdist +twine upload dist/* diff --git a/Package/python/setup.py b/Package/python/setup.py new file mode 100644 index 0000000..452f8c3 --- /dev/null +++ b/Package/python/setup.py @@ -0,0 +1,44 @@ +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +setup( + name="bellande_step", + version="0.3.3", + description="Robots Step", + long_description=long_description, + long_description_content_type="text/markdown", + author="RonaldsonBellande", + author_email="ronaldsonbellande@gmail.com", + packages=find_packages(where="src"), + package_dir={"": "src"}, + include_package_data=True, + install_requires=[ + "numpy", + ], + classifiers=[ + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python", + ], + keywords=["package", "setuptools"], + python_requires=">=3.0", + extras_require={ + "dev": ["pytest", "pytest-cov[all]", "mypy", "black"], + }, + package_data={ + 'bellande_step': ['Bellande_Step'], + }, + entry_points={ + 'console_scripts': [ + 'bellande_step_executable = bellande_step.bellande_step_executable:main', + 'bellande_step_api = bellande_step.bellande_step_api:main', + ], + }, + project_urls={ + "Home": "https://github.com/Robotics-Sensors/bellande_step", + "Homepage": "https://github.com/Robotics-Sensors/bellande_step", + "documentation": "https://github.com/Robotics-Sensors/bellande_step", + "repository": "https://github.com/Robotics-Sensors/bellande_step", + }, +) diff --git a/Package/python/src/.gitignore b/Package/python/src/.gitignore new file mode 100644 index 0000000..3bd3f0d --- /dev/null +++ b/Package/python/src/.gitignore @@ -0,0 +1 @@ +bellande_step.egg-info diff --git a/Package/python/src/__init__.py b/Package/python/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Package/python/src/bellande_step/Bellande_Step b/Package/python/src/bellande_step/Bellande_Step new file mode 100755 index 0000000..5f4247f Binary files /dev/null and b/Package/python/src/bellande_step/Bellande_Step differ diff --git a/Package/python/src/bellande_step/__init__.py b/Package/python/src/bellande_step/__init__.py new file mode 100644 index 0000000..14b2a3f --- /dev/null +++ b/Package/python/src/bellande_step/__init__.py @@ -0,0 +1,3 @@ +""" +ros_extension +""" diff --git a/Package/python/src/bellande_step/bellande_step_api.py b/Package/python/src/bellande_step/bellande_step_api.py new file mode 100644 index 0000000..4df3a53 --- /dev/null +++ b/Package/python/src/bellande_step/bellande_step_api.py @@ -0,0 +1,78 @@ +# 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 . + +#!/usr/bin/env python3 + +import requests +import argparse +import json +import sys + +def make_bellande_step_request(node0, node1, limit, dimensions): + url = "https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Step/bellande_step_nd" + + # Convert string inputs to lists if they're strings + if isinstance(node0, str): + node0 = json.loads(node0) + if isinstance(node1, str): + node1 = json.loads(node1) + + payload = { + "node0": node0, + "node1": node1, + "limit": limit, + "dimensions": dimensions, + "auth": { + "authorization_key": "bellande_web_api_opensource" + } + } + + headers = { + 'accept': 'application/json', + 'Content-Type': 'application/json' + } + + try: + response = requests.post(url, json=payload, headers=headers) + response.raise_for_status() + return response.json() + except requests.RequestException as e: + print(f"Error making request: {e}", file=sys.stderr) + sys.exit(1) + +def main(): + parser = argparse.ArgumentParser(description="Run Bellande Step API") + parser.add_argument("--node0", required=True, help="First coordinate as JSON-formatted list") + parser.add_argument("--node1", required=True, help="Second coordinate as JSON-formatted list") + parser.add_argument("--limit", type=int, required=True, help="Limit for the algorithm") + parser.add_argument("--dimensions", type=int, required=True, help="Number of dimensions") + + args = parser.parse_args() + + try: + result = make_bellande_step_request( + args.node0, + args.node1, + args.limit, + args.dimensions + ) + + print(json.dumps(result, indent=2)) + except json.JSONDecodeError as e: + print(f"Error: Invalid JSON format in coordinates - {e}", file=sys.stderr) + sys.exit(1) + +if __name__ == "__main__": + main() diff --git a/Package/python/src/bellande_step/bellande_step_executable.py b/Package/python/src/bellande_step/bellande_step_executable.py new file mode 100644 index 0000000..a2f253c --- /dev/null +++ b/Package/python/src/bellande_step/bellande_step_executable.py @@ -0,0 +1,79 @@ +# 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 . + +#!/usr/bin/env python3 + +import subprocess +import argparse +import json +import os +import sys + +def get_executable_path(): + if getattr(sys, 'frozen', False): + application_path = sys._MEIPASS + else: + application_path = os.path.dirname(os.path.abspath(__file__)) + + return os.path.join(application_path, 'Bellande_Step') + +def run_bellande_step(node0, node1, limit, dimensions): + executable_path = get_executable_path() + passcode = "bellande_step_executable_access_key" + + # Convert string representations of coordinates to actual lists + node0_list = json.loads(node0) + node1_list = json.loads(node1) + + # Validate input + if len(node1_list) != dimensions or len(node0_list) != dimensions: + raise ValueError(f"Coordinates must have {dimensions} dimensions") + + # Prepare the command + command = [ + executable_path, + passcode, + json.dumps(node0_list), + json.dumps(node1_list), + str(limit), + str(dimensions) + ] + + # Run the command + try: + result = subprocess.run(command, check=True, capture_output=True, text=True) + print(result.stdout) + except subprocess.CalledProcessError as e: + print("Error occurred:", e) + print("Error output:", e.stderr) + +def main(): + parser = argparse.ArgumentParser(description="Run Bellande Step Executable") + parser.add_argument("--node0", help="First coordinate as a JSON-formatted list") + parser.add_argument("--node1", help="Second coordinate as a JSON-formatted list") + parser.add_argument("--limit", type=int, help="Limit for the algorithm") + parser.add_argument("--dimensions", type=int, help="Number of dimensions") + + args = parser.parse_args() + + run_bellande_step( + args.node0, + args.node1, + args.limit, + args.dimensions + ) + +if __name__ == "__main__": + main() diff --git a/README.md b/README.md index 9849594..ec13837 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ You want to compute the next step from `node0` towards `node1` while limiting th ```python # Define Import -from bellande_step.bellande_step_2d import bellande_step_2d, Node2D +from bellande_step.bellande_step_2d import bellande_step_2d # Define the nodes node0 = Node2D(0, 0) @@ -209,7 +209,7 @@ You want to compute the next step from `node0` towards `node1` while limiting th ```python # Define Import -from bellande_step.bellande_step_3d import bellande_step_3d, Node3D +from bellande_step.bellande_step_3d import bellande_step_3d # Define the nodes node0 = Node3D(0, 0, 0) diff --git a/configs/bellande/http_configs.bellande b/configs/bellande/http_configs.bellande index 14a907b..dfd0673 100644 --- a/configs/bellande/http_configs.bellande +++ b/configs/bellande/http_configs.bellande @@ -16,6 +16,6 @@ url: https://bellande-robotics-sensors-research-innovation-center.org endpoint_path: - bellande_step: /api/Bellande_Step/bellande_step_nd + bellande_step: /api/Bellande_Step/bellande_step Bellande_Framework_Access_Key: bellande_web_api_opensource diff --git a/configs/bellande/tcp_configs.bellande b/configs/bellande/tcp_configs.bellande index e42fa0f..ffc3713 100644 --- a/configs/bellande/tcp_configs.bellande +++ b/configs/bellande/tcp_configs.bellande @@ -16,6 +16,6 @@ url: tcp://bellande-robotics-sensors-research-innovation-center.org endpoint_path: - bellande_step: /api/Bellande_Step/bellande_step_nd + bellande_step: /api/Bellande_Step/bellande_step Bellande_Framework_Access_Key: bellande_web_api_opensource diff --git a/configs/bellande/tls_configs.bellande b/configs/bellande/tls_configs.bellande index e67fa1d..1a28ae5 100644 --- a/configs/bellande/tls_configs.bellande +++ b/configs/bellande/tls_configs.bellande @@ -16,6 +16,6 @@ url: tls://bellande-robotics-sensors-research-innovation-center.org endpoint_path: - bellande_step: /api/Bellande_Step/bellande_step_nd + bellande_step: /api/Bellande_Step/bellande_step Bellande_Framework_Access_Key: bellande_web_api_opensource diff --git a/git_scripts/.gitignore b/git_scripts/.gitignore new file mode 100644 index 0000000..e5a7a9c --- /dev/null +++ b/git_scripts/.gitignore @@ -0,0 +1,3 @@ +fix_errors.sh +push.sh +repository_recal.sh diff --git a/run_api.bellos b/run_api.bellos index 62ea96e..1ded652 100755 --- a/run_api.bellos +++ b/run_api.bellos @@ -1,5 +1,5 @@ curl -X 'POST' \ - 'https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Step/bellande_step_nd' \ + 'https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Step/bellande_step' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ diff --git a/run_api.sh b/run_api.sh index 62ea96e..1ded652 100755 --- a/run_api.sh +++ b/run_api.sh @@ -1,5 +1,5 @@ curl -X 'POST' \ - 'https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Step/bellande_step_nd' \ + 'https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Step/bellande_step' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{