latest pushes

This commit is contained in:
2024-11-21 16:59:20 -05:00
parent c3050629b6
commit 1a1d60b952
7 changed files with 237 additions and 143 deletions

Binary file not shown.

View File

@ -0,0 +1,3 @@
"""
ros_extension
"""

View File

@ -0,0 +1,98 @@
# 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_bellande_limit_request(node0, node1, environment, size, goal, obstacles=None, search_radius=50, sample_points=20):
url = "https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Limit/bellande_limit"
# 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)
if isinstance(environment, str):
environment = json.loads(environment)
if isinstance(size, str):
size = json.loads(size)
if isinstance(goal, str):
goal = json.loads(goal)
if isinstance(obstacles, str):
obstacles = json.loads(obstacles)
payload = {
"node0": node0,
"node1": node1,
"environment": environment,
"size": size,
"goal": goal,
"obstacles": obstacles or [],
"search_radius": search_radius,
"sample_points": sample_points,
"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 Limit API")
parser.add_argument("--node0", required=True, help="Starting point coordinates as JSON-formatted list")
parser.add_argument("--node1", required=True, help="Target point coordinates as JSON-formatted list")
parser.add_argument("--environment", required=True, help="Environment dimensions as JSON-formatted list")
parser.add_argument("--size", required=True, help="Step sizes for each dimension as JSON-formatted list")
parser.add_argument("--goal", required=True, help="Goal coordinates as JSON-formatted list")
parser.add_argument("--obstacles", help="List of obstacles as JSON-formatted list of objects with 'position' and 'dimensions'")
parser.add_argument("--search-radius", type=float, default=50.0, help="Search radius for obstacle detection")
parser.add_argument("--sample-points", type=int, default=20, help="Number of sample points for obstacle detection")
args = parser.parse_args()
try:
result = make_bellande_limit_request(
args.node0,
args.node1,
args.environment,
args.size,
args.goal,
args.obstacles,
args.search_radius,
args.sample_points
)
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()

View File

@ -0,0 +1,101 @@
# 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_Limit')
def run_bellande_limit(node0, node1, environment, size, goal, obstacles=None, search_radius=50, sample_points=20):
executable_path = get_executable_path()
passcode = "bellande_limit_executable_access_key"
# Convert string representations to actual lists/objects
node0_list = json.loads(node0)
node1_list = json.loads(node1)
environment_list = json.loads(environment)
size_list = json.loads(size)
goal_list = json.loads(goal)
obstacles_list = json.loads(obstacles) if obstacles else []
# Validate input dimensions
dimensions = len(environment_list)
if not all(len(x) == dimensions for x in [node0_list, node1_list, size_list, goal_list]):
raise ValueError(f"All coordinates must have {dimensions} dimensions")
# Validate obstacles
for obstacle in obstacles_list:
if len(obstacle['position']) != dimensions or len(obstacle['dimensions']) != dimensions:
raise ValueError(f"Obstacle position and dimensions must have {dimensions} dimensions")
# Prepare the command
command = [
executable_path,
passcode,
json.dumps(node0_list),
json.dumps(node1_list),
json.dumps(environment_list),
json.dumps(size_list),
json.dumps(goal_list),
json.dumps(obstacles_list),
str(search_radius),
str(sample_points)
]
# 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 Limit Executable")
parser.add_argument("--node0", required=True, help="Starting point coordinates as JSON-formatted list")
parser.add_argument("--node1", required=True, help="Target point coordinates as JSON-formatted list")
parser.add_argument("--environment", required=True, help="Environment dimensions as JSON-formatted list")
parser.add_argument("--size", required=True, help="Step sizes for each dimension as JSON-formatted list")
parser.add_argument("--goal", required=True, help="Goal coordinates as JSON-formatted list")
parser.add_argument("--obstacles", help="List of obstacles as JSON-formatted list of objects with 'position' and 'dimensions'")
parser.add_argument("--search-radius", type=float, default=50.0, help="Search radius for obstacle detection")
parser.add_argument("--sample-points", type=int, default=20, help="Number of sample points for obstacle detection")
args = parser.parse_args()
run_bellande_limit(
args.node0,
args.node1,
args.environment,
args.size,
args.goal,
args.obstacles,
args.search_radius,
args.sample_points
)
if __name__ == "__main__":
main()