Skip to main content

Initialization

Configuring of Lively is centered on the Solver class, which you can instantiate with the following parameters:

note

If no values are provided for the optional field, the Solver will just use the default values and behaviors for the optional parameters.

ParameterTypeOptionalDefault value/behaviorDescription
urdfstringnononeURDF XML as a string.
objectiveslook-up table of Objectives indexed by a string keynononeThe initial objectives to the Solver.
root_boundslist of 6 pairs of floatsyesThe root of the robot is fixed to the world originThe list of hard limits on how much the base of the robot can move relative to the world frame. The first value in each pair is the center of the range, and the second is the delta allowed. The first 3 entries correspond to the X, Y, and Z coordinates, and the second 3 correspond to the rotation in R, P, Y euler angles
shapeslist of Shape objectsyesThere will be no other shapes beside that of the robot.The initial environmental shapes that will not be modified in a later stage. shape_update in solve will not modify these shapes. They are solely static in the scene.
initial_stateState objectsyesOnly origin and joints parameters have to be defined for the State if user decided to provide a State object to the initial_state parameterThe initial state to the Solver.
max_retriesintegeryesValue of 1 is usedIf a value bigger than 1 is provided, the new value is the maximum number of randomly initialized rounds allowed for each invocation of solve.
max_iterationsintegeryesvalue of 150 is usedIf a value other than 150 is provided, the value is the number of maximum iterations per round within the optimization.
collision_settingsCollision SettingyesSee Type DefaultsThe initial setting to Collision Avoidance.

Import

import { Solver } from "@people_and_robots/lively";

Example Solver Initialization

import { Solver } from "@people_and_robots/lively";
let solver = new Solver(
(urdf = "<?xml version='1.0' ?><robot name='panda'>...</robot>"), // Full urdf as a string
(objectives = {
//The initial objectives to the solver
eePosition: {
type: "PositionMatch", // for Javascript, the type of the objective is the name of the objective but without "Objective". For example, the type for PositionMatchObjective is PositionMatch
name: "EE Position", // name can be arbitrary
link: "torso",
weight: 4, // the weight determines the prioritization of objectives
},
eeRotation: {
type: "OrientationMatch",
name: "EE Rotation",
link: "torso",
weight: 5,
},
collision: {
type: "CollisionAvoidance",
name: "Collision Avoidance",
weight: 2,
},
}),
(root_bounds = [
{ value: basePose.position.x, delta: 0.0 },
{ value: basePose.position.y, delta: 0.0 },
{ value: basePose.position.z, delta: 0.0 }, // Translational
{ value: baseEuler[0], delta: 0.0 },
{ value: baseEuler[1], delta: 0.0 },
{ value: baseEuler[2], delta: 0.0 }, // Rotational
]),
(shapes = [
{
type: "Box", //can be 'Cylinder', 'Capsule', or 'Sphere'
name: "camera attachment", // name can be arbitrary
frame: "panda_hand", // or 'world'
physical: true, // physical collision
x: 0.5,
y: 0.5,
z: 0.2, // dimension of the box
localTransform: {
translation: [0.0, 0.0, 0.0],
rotation: [0.0, 0.0, 0.0, 1.0],
}, // [x, y, z, w] ordering for quaternion
},
]),
(initial_state = {
origin: { translation: [0, 0, 0], rotation: [1, 0, 0, 0] },
joints: { panda_joint1: 0.0, panda_joint2: 0.0 },
}), //only the origin and joints need to be defined for the state object for initial_state
(only_core = False), // Only use this flag if you are not using liveliness objectives and want a slight speed-up
(max_retries = 1), // Number of times the solution is attempted
(max_iterations = 150), // Number of iterations per try
(collision_settings = {
dMax: 0.3,
r: 0.0,
aMax: 2.0,
timeBudget: 100,
timed: true,
}) // if not provided, the solve will use the default values
);