GithubHelp home page GithubHelp logo

weiqikim / spot_mini_mini Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openquadruped/spot_mini_mini

0.0 0.0 0.0 289.59 MB

Deploying minimal-body-acceleration policy on Spot Micro quadruped using Reinforcement Learning as an Optimization Technique over an Open-Loop Bezier Gait.

Home Page: https://moribots.github.io/project/spot-mini-mini

License: MIT License

Python 90.95% CMake 1.96% C++ 4.89% Shell 2.20%

spot_mini_mini's Introduction

Spot Mini Mini OpenAI Gym Environment

GitHub release Documentation Status Maintenance PR Open Source Love png2 MIT license

SIK

Motivation

As part of the Spot Micro community, I saw the need for a reliable and versatile simulator for those who wanted to try things out without risking damage to their robots. To that end, I developed my own in Pybullet which can also be used as a Gym environment for Reinforcement Learning tasks.

If you don't need a Gym environment, that's okay too! env_tester.py works without RL or Gym, is designed to accept any gait implementation, and provides a GUI for testing it out! In my case, I've implemented a 12-point Bezier gait.

Read the docs!

Table of Contents

Kinematics:

Body manipulation with leg IK and body IK descriptions.

SIK

Reinforcement Learning

Stability on Difficult Terrain

An interesting RL challenge was to induce stability on randomized and programmatically generated rough terrain. For this challenge, a simple Proportional controller was employed to deliver yaw correction as would be the case if the robot were teleoperated or able to localize itself.For increased policy robustness, the terrain, link masses and foot frictions are randomized on each environment reset.

Here, the action space is 14-dimensional, consisting of Clearance Height (1), Body Height (1), and Foot XYZ Residual modulations (12). Clearance Height is treated through an exponential filter (alpha = 0.7), but all other actions are processed directly. These results were trained with only 149 epochs.

Before training, the robot falls almost immediately:

FALL

After training, the robot successfully navigates the terrain:

FALL

Drift Correction

I've found that the Bezier Curve gait lends itself well to optimization via RL if I intentionally select sub-optimal gait parameters. Notice that the open-loop forward command drifts significantly over time (rougly 1m per 2m forward):

DRIFT

With a one-dimensional action space [Yaw Rate], and a 16-dimensional observation space [IMU Inputs (8), Leg Phases (4), Leg Contacts (4)], an Augmented Random Search agent (linear) was able to correct the trajectory after 299 epochs:

NODRIFT

Here is the policy output for this demo. It's clearly biased on one end to account for Spot's drift:

NODRIFTPOL

Gait:

Open-Loop Gait using 12-Point Bezier Curves based on MIT Cheetah Paper with modifications for low step velocity discontinuity.

Forward and Lateral Motion:

SLAT0

Yaw logic based on 4-wheel steering car:

SYAW0

How To Run

Dependencies

  • ROS Melodic
  • Gazebo
  • Pytorch
  • Pybullet
  • Gym
  • OpenCV

Joystick Control with ROS

First, you're going to need a joystick (okay, not really, but it's more fun if you have one).

Setting Up The Joystick:

  • Get Number (you will see something like jsX): ls /dev/input/
  • Make available to ROS: sudo chmod a+rw /dev/input/jsX
  • Make sure <param name="dev" type="string" value="/dev/input/jsX"/> matches your setup in the launchfile

Then simply: roslaunch mini_ros spot_move.launch

You can ignore this msg: [ERROR] [1591631380.406690714]: Couldn't open joystick force feedback! It just means your controller is missing some functionality, but this package doesn't use it.

Controls:

Assuming you have a Logitech Gamepad F310:

A: switch between stepping and RPY

X: E-STOP (engage and disengage)

Stepping Mode:

  • Right Stick Up/Down: Step Length
  • Right Stick Left/Right: Lateral Fraction
  • Left Stick Up/Down: Robot Height
  • Left Stick Left/Right: Yaw Rate
  • Arrow Pad Up/Down (DISCRETE): Step Height
  • Arrow Pad Left/Right (DISCRETE): Step Depth
  • Bottom Right/Left Bumpers: Step Velocity (modulate)
  • Top Right/Left Bumpers: reset all to default

Viewing Mode:

  • Right Stick Up/Down: Pitch
  • Right Stick Left/Right: Roll
  • Left Stick Up/Down: Robot Height
  • Left Stick Left/Right: Yaw

Changing Step Velocity while moving forward:

SVMOD

Changing Step Length while moving forward:

SVMOD

Yaw In Place: Slightly push the Right Stick forward while pushing the Left Stick maximally in either direction:

SVMOD

Testing Environment (Non-Joystick)

If you don't have a joystick, go to spot_bullet/src and do ./env_tester.py. A Pybullet sim will open up for you with the same controls you would have on the joystick, except each is on its own scrollbar. You may also use the following optional arguments:

-h, --help          show this help message and exit
-hf, --HeightField  Use HeightField
-r, --DebugRack     Put Spot on an Elevated Rack
-p, --DebugPath     Draw Spot's Foot Path
-ay, --AutoYaw      Automatically Adjust Spot's Yaw
-ar, --AutoReset    Automatically Reset Environment When Spot Falls

Reinforcement Learning Agent Evaluation

Go to spot_bullet/src and do ./spot_ars_eval.py. You may also use the following optional arguments. Note that if you don't use the -a argument, no agent will be loaded, so you will be using the open-loop policy. For example, if you enter 149 after -a, you will see the first successful policy, but if you enter 2229, you will see a much more aggressive policy.

-h, --help          show this help message and exit
-hf, --HeightField  Use HeightField
-r, --DebugRack     Put Spot on an Elevated Rack
-p, --DebugPath     Draw Spot's Foot Path
-a, --AgentNum      Agent Number To Load

Using Different Terrain

Navigate to spotmicro/heightfield.py and take a look at useProgrammatic and useTerrainFromPNG (you can play around with the mesh scales for each) to experiment with different terrains. Make sure that the spotBezierEnv instance has height_field=True in env_tester.py and spot_pybullet_interface depending on whether you're using the joystick/ROS version. The same goes for the RL environments. Note: these were adapted from the pybullet source code.

useTerrainFromPNG

PNGT

useProgrammatic

PROGT

With this terrain type, I programmed in a randomizer that triggers upon reset. This, along with the body randomizer from Pybullet's Minitaur increases your RL Policy's robustness.

RANDENV

spot_mini_mini's People

Contributors

moribots 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.