latest pushes
This commit is contained in:
parent
e91cd8b6a7
commit
e67863164f
2
Package/rust/.gitignore
vendored
Normal file
2
Package/rust/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
target
|
||||||
|
Cargo.lock
|
24
Package/rust/Cargo.toml
Normal file
24
Package/rust/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[package]
|
||||||
|
name = "bellande_limit"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["Bellande Robotics Sensors Research Innovation Center"]
|
||||||
|
description = "Bellande Adaptive Step Size dynamically adjusts movement increments for optimal robotic path planning and navigation"
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
repository = "https://github.com/Robotics-Sensors/bellande_limit"
|
||||||
|
readme = "README.md"
|
||||||
|
keywords = ["robotics", "algorithms", "research"]
|
||||||
|
categories = ["science", "algorithms"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
structopt = "0.3"
|
||||||
|
tokio = { version = "1.0", features = ["full"] }
|
||||||
|
thiserror = "1.0"
|
||||||
|
anyhow = "1.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "bellande_limit"
|
||||||
|
path = "src/bellande_limit.rs"
|
167
Package/rust/README.md
Normal file
167
Package/rust/README.md
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
# 📦 Bellande Limit
|
||||||
|
|
||||||
|
## 🧙 Organization Website
|
||||||
|
- [![Organization Website](https://img.shields.io/badge/Explore%20Our-Website-0099cc?style=for-the-badge)](https://robotics-sensors.github.io)
|
||||||
|
|
||||||
|
## 🧙 Organization Github
|
||||||
|
- [![Organization Github ](https://img.shields.io/badge/Explore%20Our-Github-0099cc?style=for-the-badge)](https://github.com/Robotics-Sensors)
|
||||||
|
|
||||||
|
# Author, Creator and Maintainer
|
||||||
|
- **Ronaldson Bellande**
|
||||||
|
|
||||||
|
## Bellande Limit Executables & Models
|
||||||
|
- [![Bellande Limit Models & Executables ](https://img.shields.io/badge/Bellande%20Step-Models/Executables-0099cc?style=for-the-badge)](https://github.com/Artificial-Intelligence-Computer-Vision/bellande_limit_models_executables)
|
||||||
|
|
||||||
|
# API HTTP Usability (BELLANDE FORMAT)
|
||||||
|
```
|
||||||
|
# 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/>.
|
||||||
|
# GNU General Public License v3.0 or later
|
||||||
|
|
||||||
|
url: https://bellande-robotics-sensors-research-innovation-center.org
|
||||||
|
|
||||||
|
endpoint_path:
|
||||||
|
bellande_limit: /api/Bellande_Limit/bellande_limit
|
||||||
|
|
||||||
|
Bellande_Framework_Access_Key: bellande_web_api_opensource
|
||||||
|
```
|
||||||
|
|
||||||
|
# API HTTP Usability (JSON FORMAT)
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"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 <https://www.gnu.org/licenses/>.",
|
||||||
|
"GNU General Public License v3.0 or later"
|
||||||
|
],
|
||||||
|
"url": "https://bellande-robotics-sensors-research-innovation-center.org",
|
||||||
|
"endpoint_path": {
|
||||||
|
"bellande_limit": "/api/Bellande_Limit/bellande_limit"
|
||||||
|
},
|
||||||
|
"Bellande_Framework_Access_Key": "bellande_web_api_opensource"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# API Payload Example
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"node0": [0, 0, 0],
|
||||||
|
"node1": [100, 100, 100],
|
||||||
|
"environment": [1000, 1000, 1000],
|
||||||
|
"size": [10, 10, 10],
|
||||||
|
"goal": [200, 200, 200],
|
||||||
|
"obstacles": [
|
||||||
|
{
|
||||||
|
"position": [50, 50, 50],
|
||||||
|
"dimensions": [20, 20, 20]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_radius": 50,
|
||||||
|
"sample_points": 20,
|
||||||
|
"auth": {
|
||||||
|
"authorization_key": "bellande_web_api_opensource"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# 🧙 Website Bellande API Testing
|
||||||
|
- [![Website API Testing](https://img.shields.io/badge/Bellande%20API-Testing-0099cc?style=for-the-badge)](https://bellande-robotics-sensors-research-innovation-center.org/api/bellande_limit_experiment)
|
||||||
|
|
||||||
|
# Quick Bellande API Testing
|
||||||
|
```
|
||||||
|
curl -X 'POST' \
|
||||||
|
'https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Limit/bellande_limit' \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"node0": [0, 0, 0],
|
||||||
|
"node1": [100, 100, 100],
|
||||||
|
"environment": [1000, 1000, 1000],
|
||||||
|
"size": [10, 10, 10],
|
||||||
|
"goal": [100, 100, 100],
|
||||||
|
"obstacles": [
|
||||||
|
{
|
||||||
|
"position": [50, 50, 50],
|
||||||
|
"dimensions": [20, 20, 20]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_radius": 50,
|
||||||
|
"sample_points": 20,
|
||||||
|
"auth": {
|
||||||
|
"authorization_key": "bellande_web_api_opensource"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
# Bellande Limit Usage
|
||||||
|
|
||||||
|
## Website Crates
|
||||||
|
- https://crates.io/crates/bellande_limit
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
- `cargo add bellande_limit`
|
||||||
|
|
||||||
|
## Website PYPI
|
||||||
|
- https://pypi.org/project/bellande_limit
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
- `$ pip install bellande_limit`
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
```
|
||||||
|
bellande_limit_api \
|
||||||
|
--node0 "[0,0,0]" \
|
||||||
|
--node1 "[100,100,100]" \
|
||||||
|
--environment "[1000,1000,1000]" \
|
||||||
|
--size "[10,10,10]" \
|
||||||
|
--goal "[200,200,200]" \
|
||||||
|
--obstacles '[{"position":[50,50,50],"dimensions":[20,20,20]}]' \
|
||||||
|
--search-radius 50 \
|
||||||
|
--sample-points 20
|
||||||
|
```
|
||||||
|
|
||||||
|
### Upgrade (if not upgraded)
|
||||||
|
- `$ pip install --upgrade bellande_limit`
|
||||||
|
|
||||||
|
```
|
||||||
|
Name: bellande_limit
|
||||||
|
Summary: Computes the next step towards a target node
|
||||||
|
Home-page: github.com/RonaldsonBellande/bellande_limit
|
||||||
|
Author: Ronaldson Bellande
|
||||||
|
Author-email: ronaldsonbellande@gmail.com
|
||||||
|
License: GNU General Public License v3.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Published Paper
|
||||||
|
```
|
||||||
|
Coming Soon
|
||||||
|
```
|
||||||
|
|
||||||
|
## Preprint
|
||||||
|
- [![Preprint](https://img.shields.io/badge/Preprint-Bellande%20Step-0099cc?style=for-the-badge)](https://dapp.orvium.io/deposits/6650ccb8afb407dc8beb0ff2/view)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
This Algorithm or Models is distributed under the [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/), see [LICENSE](https://github.com/RonaldsonBellande/bellande_step/blob/main/LICENSE) and [NOTICE](https://github.com/RonaldsonBellande/bellande_step/blob/main/LICENSE) for more information.
|
4
Package/rust/publish.sh
Executable file
4
Package/rust/publish.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
cp ../../README.md .
|
||||||
|
bash ../../git_scripts/push.sh
|
||||||
|
cargo publish
|
||||||
|
rm -f README.md
|
256
Package/rust/src/bellande_limit.rs
Normal file
256
Package/rust/src/bellande_limit.rs
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
use std::error::Error;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::{self, Command};
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
#[derive(StructOpt, Debug)]
|
||||||
|
#[structopt(name = "bellande_limit", about = "Bellande Limit Tool")]
|
||||||
|
struct Opt {
|
||||||
|
#[structopt(long, help = "Starting point coordinates as JSON-formatted list")]
|
||||||
|
node0: String,
|
||||||
|
|
||||||
|
#[structopt(long, help = "Target point coordinates as JSON-formatted list")]
|
||||||
|
node1: String,
|
||||||
|
|
||||||
|
#[structopt(long, help = "Environment dimensions as JSON-formatted list")]
|
||||||
|
environment: String,
|
||||||
|
|
||||||
|
#[structopt(long, help = "Step sizes for each dimension as JSON-formatted list")]
|
||||||
|
size: String,
|
||||||
|
|
||||||
|
#[structopt(long, help = "Goal coordinates as JSON-formatted list")]
|
||||||
|
goal: String,
|
||||||
|
|
||||||
|
#[structopt(long, help = "List of obstacles as JSON-formatted list")]
|
||||||
|
obstacles: Option<String>,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
default_value = "50.0",
|
||||||
|
help = "Search radius for obstacle detection"
|
||||||
|
)]
|
||||||
|
search_radius: f64,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
default_value = "20",
|
||||||
|
help = "Number of sample points for obstacle detection"
|
||||||
|
)]
|
||||||
|
sample_points: i32,
|
||||||
|
|
||||||
|
#[structopt(long, help = "Use local executable instead of API")]
|
||||||
|
use_executable: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn make_bellande_limit_request(
|
||||||
|
node0: Value,
|
||||||
|
node1: Value,
|
||||||
|
environment: Value,
|
||||||
|
size: Value,
|
||||||
|
goal: Value,
|
||||||
|
obstacles: Option<Value>,
|
||||||
|
search_radius: f64,
|
||||||
|
sample_points: i32,
|
||||||
|
) -> Result<Value, Box<dyn Error>> {
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let url = "https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Limit/bellande_limit";
|
||||||
|
|
||||||
|
let payload = json!({
|
||||||
|
"node0": node0,
|
||||||
|
"node1": node1,
|
||||||
|
"environment": environment,
|
||||||
|
"size": size,
|
||||||
|
"goal": goal,
|
||||||
|
"obstacles": obstacles.unwrap_or(json!([])),
|
||||||
|
"search_radius": search_radius,
|
||||||
|
"sample_points": sample_points,
|
||||||
|
"auth": {
|
||||||
|
"authorization_key": "bellande_web_api_opensource"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let response = client
|
||||||
|
.post(url)
|
||||||
|
.header("accept", "application/json")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.json(&payload)
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.json::<Value>()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_executable_path() -> PathBuf {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
Path::new(env!("CARGO_MANIFEST_DIR")).join("Bellande_Limit.exe")
|
||||||
|
} else {
|
||||||
|
Path::new(env!("CARGO_MANIFEST_DIR")).join("Bellande_Limit")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_bellande_limit_executable(
|
||||||
|
node0: &str,
|
||||||
|
node1: &str,
|
||||||
|
environment: &str,
|
||||||
|
size: &str,
|
||||||
|
goal: &str,
|
||||||
|
obstacles: Option<&str>,
|
||||||
|
search_radius: f64,
|
||||||
|
sample_points: i32,
|
||||||
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
let executable_path = get_executable_path();
|
||||||
|
let passcode = "bellande_limit_executable_access_key";
|
||||||
|
|
||||||
|
// Parse and validate inputs
|
||||||
|
let node0_list: Value = serde_json::from_str(node0)?;
|
||||||
|
let node1_list: Value = serde_json::from_str(node1)?;
|
||||||
|
let environment_list: Value = serde_json::from_str(environment)?;
|
||||||
|
let size_list: Value = serde_json::from_str(size)?;
|
||||||
|
let goal_list: Value = serde_json::from_str(goal)?;
|
||||||
|
let obstacles_list: Value = obstacles
|
||||||
|
.map(|o| serde_json::from_str(o))
|
||||||
|
.transpose()?
|
||||||
|
.unwrap_or(json!([]));
|
||||||
|
|
||||||
|
// Validate dimensions
|
||||||
|
let dimensions = environment_list.as_array().unwrap().len();
|
||||||
|
if let (Some(n0), Some(n1), Some(s), Some(g)) = (
|
||||||
|
node0_list.as_array(),
|
||||||
|
node1_list.as_array(),
|
||||||
|
size_list.as_array(),
|
||||||
|
goal_list.as_array(),
|
||||||
|
) {
|
||||||
|
if n0.len() != dimensions
|
||||||
|
|| n1.len() != dimensions
|
||||||
|
|| s.len() != dimensions
|
||||||
|
|| g.len() != dimensions
|
||||||
|
{
|
||||||
|
return Err(format!("All coordinates must have {} dimensions", dimensions).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate obstacles
|
||||||
|
if let Some(obstacles) = obstacles_list.as_array() {
|
||||||
|
for obstacle in obstacles {
|
||||||
|
if let (Some(pos), Some(dims)) = (
|
||||||
|
obstacle.get("position").and_then(Value::as_array),
|
||||||
|
obstacle.get("dimensions").and_then(Value::as_array),
|
||||||
|
) {
|
||||||
|
if pos.len() != dimensions || dims.len() != dimensions {
|
||||||
|
return Err(
|
||||||
|
"Obstacle position and dimensions must match environment dimensions".into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare and run command
|
||||||
|
let mut command = Command::new(executable_path);
|
||||||
|
command.args(&[
|
||||||
|
passcode,
|
||||||
|
node0,
|
||||||
|
node1,
|
||||||
|
environment,
|
||||||
|
size,
|
||||||
|
goal,
|
||||||
|
&serde_json::to_string(&obstacles_list)?,
|
||||||
|
&search_radius.to_string(),
|
||||||
|
&sample_points.to_string(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let output = command.output()?;
|
||||||
|
|
||||||
|
if output.status.success() {
|
||||||
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(format!(
|
||||||
|
"Process failed: {}",
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
)
|
||||||
|
.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let opt = Opt::from_args();
|
||||||
|
|
||||||
|
// Parse JSON strings to Values for validation
|
||||||
|
let node0: Value =
|
||||||
|
serde_json::from_str(&opt.node0).map_err(|e| format!("Error parsing node0: {}", e))?;
|
||||||
|
let node1: Value =
|
||||||
|
serde_json::from_str(&opt.node1).map_err(|e| format!("Error parsing node1: {}", e))?;
|
||||||
|
let environment: Value = serde_json::from_str(&opt.environment)
|
||||||
|
.map_err(|e| format!("Error parsing environment: {}", e))?;
|
||||||
|
let size: Value =
|
||||||
|
serde_json::from_str(&opt.size).map_err(|e| format!("Error parsing size: {}", e))?;
|
||||||
|
let goal: Value =
|
||||||
|
serde_json::from_str(&opt.goal).map_err(|e| format!("Error parsing goal: {}", e))?;
|
||||||
|
let obstacles_ref = opt.obstacles.as_ref();
|
||||||
|
let obstacles: Option<Value> = obstacles_ref
|
||||||
|
.map(|o| serde_json::from_str(o))
|
||||||
|
.transpose()
|
||||||
|
.map_err(|e| format!("Error parsing obstacles: {}", e))?;
|
||||||
|
|
||||||
|
if opt.use_executable {
|
||||||
|
// Run using local executable
|
||||||
|
if let Err(e) = run_bellande_limit_executable(
|
||||||
|
&opt.node0,
|
||||||
|
&opt.node1,
|
||||||
|
&opt.environment,
|
||||||
|
&opt.size,
|
||||||
|
&opt.goal,
|
||||||
|
obstacles_ref.map(String::as_str),
|
||||||
|
opt.search_radius,
|
||||||
|
opt.sample_points,
|
||||||
|
) {
|
||||||
|
eprintln!("Error: {}", e);
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Run using API
|
||||||
|
match make_bellande_limit_request(
|
||||||
|
node0,
|
||||||
|
node1,
|
||||||
|
environment,
|
||||||
|
size,
|
||||||
|
goal,
|
||||||
|
obstacles,
|
||||||
|
opt.search_radius,
|
||||||
|
opt.sample_points,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(result) => {
|
||||||
|
println!("{}", serde_json::to_string_pretty(&result)?);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Error: {}", e);
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -115,6 +115,14 @@ curl -X 'POST' \
|
|||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Bellande Limit Usage
|
||||||
|
|
||||||
|
## Website Crates
|
||||||
|
- https://crates.io/crates/bellande_limit
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
- `cargo add bellande_limit`
|
||||||
|
|
||||||
## Website PYPI
|
## Website PYPI
|
||||||
- https://pypi.org/project/bellande_limit
|
- https://pypi.org/project/bellande_limit
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user