latest pushes
This commit is contained in:
1
Package/python/.gitignore
vendored
Normal file
1
Package/python/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
dist
|
4
Package/python/publish.sh
Executable file
4
Package/python/publish.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
cp ../../README.md ./
|
||||
python setup.py sdist
|
||||
twine upload dist/*
|
||||
rm -r ./README.md
|
44
Package/python/setup.py
Normal file
44
Package/python/setup.py
Normal file
@@ -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_limit",
|
||||
version="0.1.2",
|
||||
description="Robots Limit",
|
||||
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_limit': ['Bellande_Limit'],
|
||||
},
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'bellande_limit_executable = bellande_limit.bellande_limit_executable:main',
|
||||
'bellande_limit_api = bellande_limit.bellande_limit_api:main',
|
||||
],
|
||||
},
|
||||
project_urls={
|
||||
"Home": "https://github.com/Robotics-Sensors/bellande_limit",
|
||||
"Homepage": "https://github.com/Robotics-Sensors/bellande_limit",
|
||||
"documentation": "https://github.com/Robotics-Sensors/bellande_limit",
|
||||
"repository": "https://github.com/Robotics-Sensors/bellande_limit",
|
||||
},
|
||||
)
|
1
Package/python/src/.gitignore
vendored
Normal file
1
Package/python/src/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bellande_node_importance.egg-info
|
0
Package/python/src/__init__.py
Normal file
0
Package/python/src/__init__.py
Normal file
3
Package/python/src/bellande_limit/__init__.py
Normal file
3
Package/python/src/bellande_limit/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
ros_extension
|
||||
"""
|
@@ -0,0 +1,96 @@
|
||||
# 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
|
||||
def make_node_importance_request(node, nodes, important_nodes, adjacent_segments, grid_steps, min_segment_coverage=0.5):
|
||||
url = "https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Node_Importance/node_importance"
|
||||
|
||||
# Convert string inputs to Python objects if they're strings
|
||||
if isinstance(node, str):
|
||||
node = json.loads(node)
|
||||
if isinstance(nodes, str):
|
||||
nodes = json.loads(nodes)
|
||||
if isinstance(important_nodes, str):
|
||||
important_nodes = json.loads(important_nodes)
|
||||
if isinstance(adjacent_segments, str):
|
||||
adjacent_segments = json.loads(adjacent_segments)
|
||||
if isinstance(grid_steps, str):
|
||||
grid_steps = json.loads(grid_steps)
|
||||
|
||||
payload = {
|
||||
"node": node,
|
||||
"nodes": nodes,
|
||||
"important_nodes": important_nodes,
|
||||
"adjacent_segments": adjacent_segments,
|
||||
"grid_steps": grid_steps,
|
||||
"min_segment_coverage": min_segment_coverage,
|
||||
"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 Node Importance API")
|
||||
parser.add_argument("--node", required=True,
|
||||
help="Node to evaluate as JSON object with 'coords' and 'segment'")
|
||||
parser.add_argument("--nodes", required=True,
|
||||
help="List of recent nodes as JSON array of objects with 'coords' and 'segment'")
|
||||
parser.add_argument("--important-nodes", required=True,
|
||||
help="Dictionary of important nodes by segment as JSON object")
|
||||
parser.add_argument("--adjacent-segments", required=True,
|
||||
help="Dictionary of adjacent segments as JSON object")
|
||||
parser.add_argument("--grid-steps", required=True,
|
||||
help="Grid step sizes for each dimension as JSON array")
|
||||
parser.add_argument("--min-segment-coverage", type=float, default=0.5,
|
||||
help="Minimum required segment coverage ratio")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
result = make_node_importance_request(
|
||||
args.node,
|
||||
args.nodes,
|
||||
args.important_nodes,
|
||||
args.adjacent_segments,
|
||||
args.grid_steps,
|
||||
args.min_segment_coverage
|
||||
)
|
||||
|
||||
print(json.dumps(result, indent=2))
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Error: Invalid JSON format in input parameters - {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -0,0 +1,104 @@
|
||||
# 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#!/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_Node_Importance')
|
||||
|
||||
def run_node_importance(node, nodes, important_nodes, adjacent_segments, grid_steps, min_segment_coverage=0.5):
|
||||
executable_path = get_executable_path()
|
||||
passcode = "bellande_node_importance_executable_access_key"
|
||||
|
||||
# Convert string representations to actual objects
|
||||
node_obj = json.loads(node)
|
||||
nodes_list = json.loads(nodes)
|
||||
important_nodes_dict = json.loads(important_nodes)
|
||||
adjacent_segments_dict = json.loads(adjacent_segments)
|
||||
grid_steps_list = json.loads(grid_steps)
|
||||
|
||||
# Validate input dimensions
|
||||
dimensions = len(node_obj['coords'])
|
||||
if not all(len(n['coords']) == dimensions for n in nodes_list):
|
||||
raise ValueError(f"All nodes must have {dimensions} dimensions")
|
||||
|
||||
# Validate important nodes dimensions
|
||||
for segment_nodes in important_nodes_dict.values():
|
||||
if not all(len(n['coords']) == dimensions for n in segment_nodes):
|
||||
raise ValueError(f"All important nodes must have {dimensions} dimensions")
|
||||
|
||||
# Validate grid steps
|
||||
if len(grid_steps_list) != dimensions:
|
||||
raise ValueError(f"Grid steps must have {dimensions} dimensions")
|
||||
|
||||
# Prepare the command
|
||||
command = [
|
||||
executable_path,
|
||||
passcode,
|
||||
json.dumps(node_obj),
|
||||
json.dumps(nodes_list),
|
||||
json.dumps(important_nodes_dict),
|
||||
json.dumps(adjacent_segments_dict),
|
||||
json.dumps(grid_steps_list),
|
||||
str(min_segment_coverage)
|
||||
]
|
||||
|
||||
# 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 Node Importance Executable")
|
||||
parser.add_argument("--node", required=True,
|
||||
help="Node to evaluate as JSON object with 'coords' and 'segment'")
|
||||
parser.add_argument("--nodes", required=True,
|
||||
help="List of recent nodes as JSON array of objects with 'coords' and 'segment'")
|
||||
parser.add_argument("--important-nodes", required=True,
|
||||
help="Dictionary of important nodes by segment as JSON object")
|
||||
parser.add_argument("--adjacent-segments", required=True,
|
||||
help="Dictionary of adjacent segments as JSON object")
|
||||
parser.add_argument("--grid-steps", required=True,
|
||||
help="Grid step sizes for each dimension as JSON array")
|
||||
parser.add_argument("--min-segment-coverage", type=float, default=0.5,
|
||||
help="Minimum required segment coverage ratio")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
run_node_importance(
|
||||
args.node,
|
||||
args.nodes,
|
||||
args.important_nodes,
|
||||
args.adjacent_segments,
|
||||
args.grid_steps,
|
||||
args.min_segment_coverage
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user