Coder Social home page Coder Social logo

tensegrityrobot's Introduction

Tensegrity Robot

Design, fabrication, control and simulation of tensegrity robots

Dependencies

  • Ubuntu
  • Python 3.8.16 (Anaconda)
  • Gymnasium 0.28.1 + Mujoco 2.3.3 (See Documentation)
  • Stable baselines 3 for Gymnasium (See Installation)
  • Pytorch 1.13.1

XML Builder for Tensegrity

The class Tensegrity in src/TesengrityModel/tensegrity_builder.py can automatically generate an XML model, which can be directly loaded by Mujoco.

Just input coordinates of nodes, pairs of bars and cables, and generate the XML model! (Of course, numpy.ndarray is strongly recommended)

Warning:

The Mujoco model for tensegrity may not be accurate, since it has not yet been verified by the real world.

Gymnasium Environment for Tensegrity

A Gymnasium environment has been built for tensegrity robots.

Action Space

Observation Space

Observations consist of position values of different parts of the tensegrity, followed by the velocities of these parts.

By default, observations do not include the x- and y-coordinates of bar1 of the tensegrity. These may be included by passing exclude_current_positions_from_obs=False during construction. In that case, the observation space will have 13*{number of bars} dimensions where the first two dimensions represent the x- and y- coordinates of bar1. Regardless of whether exclude_current_positions_from_obs was set to true or false, the x- and y-coordinates of bar1 will be returned in info with keys "x_position" and "y_position", respectively.

However, by default, an observation is a ndarray with shape (13*{number of bars}-2,)

The (x,y,z) coordinates are translational DOFs while the orientations are rotational DOFs expressed as quaternions.One can read more about free joints on the Mujoco Documentation.

Rewards

The reward consists of three parts:

  • healthy_reward: Every timestep that the tensegrity is healthy (see definition in section "Episode Termination"), it gets a reward of fixed value healthy_reward
  • forward_reward: A reward of moving forward which is measured as (x-coordinate before action - x-coordinate after action)/dt. dt is the time between actions and is dependent on the frame_skip parameter (default is 5), where the frametime is 0.01 - making the default dt = 5 * 0.01 = 0.05. This reward would be positive if the tensegrity moves forward (in positive x direction).
  • ctrl_cost: A negative reward for penalising the tensegrity if it takes actions that are too large. It is measured as ctrl_cost_weight * sum(action2) where ctr_cost_weight is a parameter set for the control and has a default value of 0.05.

The total reward returned is reward = healthy_reward + forward_reward - ctrl_cost.

Starting State

All observations start in state with a uniform noise in the range of [-reset_noise_scale, reset_noise_scale] added to the positional values and standard normal noise with mean 0 and standard deviation reset_noise_scale added to the velocity values for stochasticity. The initial orientation is designed to make it face forward as well.

Episode End

The tensegrity is said to be unhealthy if any of the following happens:

  1. Any of the state space values is no longer finite
  2. The z-coordinate of the tensegrity is not in the closed interval given by healthy_z_range (defaults to [-0.2, 5.0])

If terminate_when_unhealthy=True is passed during construction (which is the default), the episode ends when any of the following happens:

  1. Truncation: The episode duration reaches a 1000 timesteps
  2. Termination: The tensengrity is unhealthy

If terminate_when_unhealthy=False is passed, the episode is ended only when 1000 timesteps are exceeded.

Exploration of Tensegrity Design Space

GA is applied to explore the design space of tensegrity. To use GA, import tensegrity_ga and initiate the TensegrityGA class.

import src.TensegrityModel.tensegrity_ga as ga
tensegrity_ga = ga.TensegrityGA(6)
tensegrity_ga.run()
print(tensegrity_ga.best_individual[0])

Encoding

Please refer to the following article:

Paul, Chandana, Hod Lipson, and Francisco J. Valero Cuevas. "Evolutionary form-finding of tensegrity structures." Proceedings of the 7th annual conference on Genetic and evolutionary computation. 2005.

Fitness

Warning: Fitness function is still under development.

Temporarily, volume of the bounding box is selected as the fitness criterion.

tensegrityrobot's People

Contributors

oscarjin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.