Advanced Initialization
note
Since Lively is still in beta, the design is subject to change and should not be considered final!
We have also created examples in Javascript, Python, and Rust for Advanced Initialization. You can find the file by clicking the links in the table down below.
Language | Path | Command to run the example |
---|---|---|
Rust | link | cargo run --package lively --example advanced_initialization_example |
Python | link | run in the Jupyter Notebook |
Javascript | link | yarn build , yarn dev |
- Live
- Javascript
- Python
- Rust
Loading Example...
import { panda, ur3e } from './urdfs.js';
import { Solver } from '@people_and_robots/lively';
const initialRootBounds = [
// An exmaple of root bounds
{ value: 0.0, delta: 0.0 },
{ value: 0.25, delta: 0.0 },
{ value: 0.5, delta: 0.0 },
{ value: 0.0, delta: 0.0 },
{ value: 0.0, delta: 0.0 },
{ value: 0.0, delta: 0.0 },
];
const initialObjectives = {
smoothness: {
// An example objective (smoothness macro)
name: 'MySmoothnessObjective',
type: 'SmoothnessMacro',
weight: 5,
},
collision: {
// An example objective (collision avoidance)
name: 'MyCollisionDetection',
type: 'CollisionAvoidance',
weight: 5,
},
jointLimit: {
// An example objective (joint limit)
name: 'MyJointLimit',
type: 'JointLimits',
weight: 5,
},
};
const initialEnvShapes = [
{
type: 'Cylinder', // The Cylinder here is an example of static environmental shape. This shape will be not able to be moved or deleted.
name: 'pill',
frame: 'world',
physical: true,
length: 0.3,
radius: 0.2,
localTransform: {
translation: [-0.8, 0.0, 0.1],
rotation: [1.0, 0.0, 0.0, 0.0],
}, // [x, y, z, w] ordering for quaternion
},
];
const collision_settings = {
// This is an example of customized collision_settings
dMax: 0.1,
r: 0.0,
aMax: 2.0,
timeBudget: 100,
timed: false,
};
const newSolver = new Solver(
panda,
initialObjectives,
initialRootBounds,
initialEnvShapes,
null,
null,
null,
collision_settings
);
newSolver.computeAverageDistanceTable();
const newState = newSolver.solve({}, {}, 0.0);
document.querySelector('#app').innerHTML = `
<div>
${JSON.stringify(newState)}
</div>`;
console.log(newState);
from lively import Solver, SmoothnessMacroObjective
# Instantiate a new solver
solver = Solver(
urdf='<?xml version="1.0" ?><robot name="panda">...</robot>', # Full urdf as a string
objectives={
# An example objective (smoothness macro)
"smoothness":SmoothnessMacroObjective(name="MySmoothnessObjective",weight=5)
}
)
# Run solve to get a solved state
state = solver.solve({},{},0.0)
# Log the initial state
print(state)
use lively::lively::Solver;
use lively::objectives::core::base::SmoothnessMacroObjective;
use lively::objectives::objective::Objective;
use std::collections::HashMap;
// Create a map of objectives
let mut objectives: HashMap<String,Objective> = HashMap::new();
// Add a Smoothness Macro Objective
objectives.insert(
"smoothness".into(),
// An example objective (smoothness macro)
Objective::SmoothnessMacro(SmoothnessMacroObjective::new("MySmoothnessObjective",5.0))
);
// Instantiate a new solver struct
let mut solver = Solver::new(
urdf:'<?xml version="1.0" ?><robot name="panda">...</robot>', // Full urdf as a string
objectives
);
// Run solve to get a solved state
let state = solver.solve(
HashMap::new(),
HashMap::new(),
0.0,
None
);
// Log the initial state
println!("{:?}",state);