Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Wisc-HCI/lively
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterZh37 committed Oct 4, 2022
2 parents 21de5be + b0a6b02 commit 70701ef
Show file tree
Hide file tree
Showing 22 changed files with 586 additions and 102 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Cargo.lock
**/*.rs.bk

build/**
lively_tk.egg-info
lively.egg-info
dist**
lively_tk/__pycache__/__init__.*
lively_tk/lively_tk.cpython-*
lively/__pycache__/__init__.*
lively/lively_tk.cpython-*
tests/.ipynb_checkpoints
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "lively_tk"
name = "lively"
version = "0.10.0"
description = "A real-time robot control framework with liveliness."
repository = "https://github.com/Wisc-HCI/lively_tk"
homepage = "https://wisc-hci.github.io/lively_tk/"
repository = "https://github.com/Wisc-HCI/lively"
homepage = "https://wisc-hci.github.io/lively/"
license = "MIT"
authors = ["djrakita <[email protected]>","andrewjschoen <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -72,6 +72,6 @@ debug = true
codegen-units = 1

[lib]
name = "lively_tk"
name = "lively"
path = "src/lib.rs"
crate-type = ["rlib", "cdylib"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 UW Graphics Group
Copyright (c) 2022 People and Robots Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
87 changes: 80 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[![PyPI version](https://img.shields.io/pypi/v/lively_tk)](https://badge.fury.io/py/lively_tk)
![Upload Python Package](https://github.com/Wisc-HCI/lively_tk/workflows/Upload%20Python%20Package/badge.svg)
# LivelyTK v0.10.0 (beta)
# Lively v0.10.0 (beta)

_NOTE: Since LivelyTK is still in beta, the design is subject to change and should not be considered final!_
_NOTE: Since Lively is still in beta, the design is subject to change and should not be considered final!_

## About

LivelyTK Package
Lively Package

The LivelyTK framework provides a highly configurable toolkit for commanding robots in mixed modalities while incorporating liveliness motions. It is adapted from [RelaxedIK](https://github.com/uwgraphics/relaxed_ik_core) framework, and compatible with Python and Javascript/Node.
The Lively framework provides a highly configurable toolkit for commanding robots in mixed modalities while incorporating liveliness motions. It is adapted from [RelaxedIK](https://github.com/uwgraphics/relaxed_ik_core) framework, and compatible with Python and Javascript/Node.

To configure a robot, the easiest method is to use the LivelyStudio interface in the [lively_tk_ros](https://github.com/Wisc-HCI/lively_tk_ros) repository, which is a wizard for configuring the robot.
To configure a robot, the easiest method is to use the LivelyStudio interface in the [LivelyStudio](https://github.com/Wisc-HCI/LivelyStudio) repository, which is a system for configuring and programming the robot visually.

## Configuring

Configuring of LivelyTK is centered on the Solver class, which you can instantiate in the following ways:
Configuring of Lively is centered on the Solver class, which you can instantiate in the following ways:

_python_
```python
Expand Down Expand Up @@ -204,7 +204,7 @@ solver.reset(

## Solving

The `Solver` class has a `solve` method that represents the core functionality of the LivelyTK interface. At a high level, it accepts the following fields:
The `Solver` class has a `solve` method that represents the core functionality of the Lively interface. At a high level, it accepts the following fields:

1. `goals`: A look-up table of goal-type objects. The key of the look-up table should match with that of the objectives to which the goals are corresponded.
2. `weights`: A look-up table of floats, order corresponding to the order of the objectives. The key of the look-up table should match with that of the objectives to which the weights are corresponded.
Expand Down Expand Up @@ -469,9 +469,81 @@ A list of all shapes that are currently tracked and that reach close enough prox
A translation (vector) indicating the current center of mass of the robot.
## Extending the system.
Extending the set of objectives involves two main steps. The first step is defining the objective itself. These are generally located within the `/src/objectives/` folder. When implementing an objective, you will want to import the "Callable" trait (and possibly groove_loss) with the following:
```rust
use crate::objectives::objective::{groove_loss, Callable};
```
For your new objective, you will need the struct block, which defines the data it encodes. As an example, Position Match defines the following:
```rust
pub struct PositionMatchObjective {
pub name: String,
pub weight: f64,
pub link: String,
// Goal Value
#[serde(skip)]
pub goal: Vector3<f64>,
}
```
** Note, serde is used to assist in building web bindings. Goals are skipped for this attribute because they are defined by the user explicitly
Second is the implementation for the constructor. Here is the Position Match objective again:
```rust
impl PositionMatchObjective {
pub fn new(name: String, weight: f64, link: String) -> Self {
Self {
name,
weight,
link,
goal: vector![0.0, 0.0, 0.0], // Default to a sensible value
}
}
}
```
Finally, you need to define the implementation of the `Callable` trait:
```rust
impl Callable<Vector3<f64>> for PositionMatchObjective {
fn call(&self, _v: &Vars, state: &State) -> f64 {
// Get the link transform from frames
let link_translation = state.get_link_transform(&self.link).translation.vector;
// Calculate the distance
let x_val = (link_translation - self.goal).norm();
// Regularize by the groove_loss function and apply the weight.
return self.weight * groove_loss(x_val, 0., 2, 0.1, 10.0, 2);
}

// Implement the set_goal method
fn set_goal(&mut self, goal: Vector3<f64>) {
self.goal = goal;
}

// Implement the set_weight method
fn set_weight(&mut self, weight: f64) {
self.weight = weight;
}

// Other methods can use the default trait version.
}
```
The next main step is inserting the objective into the `Objective` enum, located in `/src/objectives/objective.rs`.
```rust
pub enum Objective {
PositionMatch(PositionMatchObjective),
OrientationMatch(OrientationMatchObjective),
...
// ++++++ Insert your Objective here ++++++
```
Finally, the `Objective` enum defines a number of functions, mainly aimed at supporting debugging or executing the functions defined in the objective trait. Follow the patterns and descriptoins located in the file for more detail.
## Contributing
Expand Down Expand Up @@ -510,6 +582,7 @@ wasm-pack pack
wasm-pack publish --access=public
```
## References
[^1]:Rakita, Daniel, Bilge Mutlu, and Michael Gleicher. "PROXIMA: An Approach for Time or Accuracy Budgeted Collision Proximity Queries." Proceedings of Robotics: Science and Systems (RSS). 2022. http://www.roboticsproceedings.org/rss18/p043.pdf
Expand Down
16 changes: 8 additions & 8 deletions examples/bevy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use bevy::{
time::{FixedTimestep},
};

use lively_tk::lively_tk::Solver;
use lively_tk::objectives::core::base::CollisionAvoidanceObjective;
use lively_tk::objectives::core::base::SmoothnessMacroObjective;
use lively_tk::objectives::core::matching::PositionMatchObjective;
use lively_tk::objectives::objective::Objective;
use lively_tk::utils::goals::Goal;
use lively_tk::utils::info::TransformInfo;
use lively_tk::utils::shapes::*;
use lively::lively::Solver;
use lively::objectives::core::base::CollisionAvoidanceObjective;
use lively::objectives::core::base::SmoothnessMacroObjective;
use lively::objectives::core::matching::PositionMatchObjective;
use lively::objectives::objective::Objective;
use lively::utils::goals::Goal;
use lively::utils::info::TransformInfo;
use lively::utils::shapes::*;
use nalgebra::geometry::Translation3;
use nalgebra::Isometry3;
use smooth_bevy_cameras::{
Expand Down
26 changes: 13 additions & 13 deletions examples/empty.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use lively_tk::lively_tk::Solver;
use lively_tk::objectives::core::base::CollisionAvoidanceObjective;
use lively_tk::objectives::core::base::SmoothnessMacroObjective;
use lively_tk::objectives::core::matching::PositionMatchObjective;
use lively_tk::objectives::objective::Objective;
use lively_tk::utils::goals::Goal::ScalarRange;
use lively_tk::utils::goals::{Goal};
use lively_tk::utils::shapes::*;
use lively_tk::utils::info::{*};
use lively_tk::utils::shapes::Shape;
use lively::lively::Solver;
use lively::objectives::core::base::CollisionAvoidanceObjective;
use lively::objectives::core::base::SmoothnessMacroObjective;
use lively::objectives::core::matching::PositionMatchObjective;
use lively::objectives::objective::Objective;
use lively::utils::goals::Goal::ScalarRange;
use lively::utils::goals::{Goal};
use lively::utils::shapes::*;
use lively::utils::info::{*};
use lively::utils::shapes::Shape;
use nalgebra::base::Vector4;
use nalgebra::base::Vector3;
use nalgebra::geometry::Isometry3;
Expand Down Expand Up @@ -57,9 +57,9 @@ fn main() {
objectives.insert("sdfsddsfes".into(),Objective::CollisionAvoidance(col_avoid_obj));
objectives.insert("dfawdaseas".into(),Objective::SmoothnessMacro(smooth_macro_obj));
// vec![
// // lively_tk_lib::objectives::objective::Objective::PositionMatch(pos_match_obj),
// // lively_tk_lib::objectives::objective::Objective::CollisionAvoidance(col_avoid_obj),
// // lively_tk_lib::objectives::objective::Objective::SmoothnessMacro(smooth_macro_obj),
// // lively_lib::objectives::objective::Objective::PositionMatch(pos_match_obj),
// // lively_lib::objectives::objective::Objective::CollisionAvoidance(col_avoid_obj),
// // lively_lib::objectives::objective::Objective::SmoothnessMacro(smooth_macro_obj),
// ];
let mut goals: HashMap<String,Goal> = HashMap::new();
let mut weights: HashMap<String,f64> = HashMap::new();
Expand Down
20 changes: 10 additions & 10 deletions examples/puffin.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use lively_tk::lively_tk::Solver;
use lively_tk::objectives::core::base::CollisionAvoidanceObjective;
use lively_tk::objectives::core::base::SmoothnessMacroObjective;
use lively_tk::objectives::core::matching::PositionMatchObjective;
use lively_tk::objectives::objective::Objective;
use lively_tk::utils::goals::Goal;
use lively_tk::utils::goals::Goal::ScalarRange;
use lively_tk::utils::info::*;
use lively_tk::utils::shapes::Shape;
use lively_tk::utils::shapes::*;
use lively::lively::Solver;
use lively::objectives::core::base::CollisionAvoidanceObjective;
use lively::objectives::core::base::SmoothnessMacroObjective;
use lively::objectives::core::matching::PositionMatchObjective;
use lively::objectives::objective::Objective;
use lively::utils::goals::Goal;
use lively::utils::goals::Goal::ScalarRange;
use lively::utils::info::*;
use lively::utils::shapes::Shape;
use lively::utils::shapes::*;
use nalgebra::base::Vector3;
use nalgebra::base::Vector4;
use nalgebra::geometry::Isometry3;
Expand Down
Loading

0 comments on commit 70701ef

Please sign in to comment.