Code Monkey home page Code Monkey logo

openquadruped / spot_mini_mini Goto Github PK

View Code? Open in Web Editor NEW
780.0 41.0 166.0 863.07 MB

Dynamics and Domain Randomized Gait Modulation with Bezier Curves for Sim-to-Real Legged Locomotion.

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

License: MIT License

Python 12.72% CMake 0.23% C++ 77.79% Shell 0.25% HTML 9.02%
quadruped locomotion reinforcement-learning pybullet environment ros optimization control open-source quadruped-robot-gaits

spot_mini_mini's Introduction

Note: development for this project was haulted in November 2020 to respect my NDA with my employer.

Spot Mini Mini OpenAI Gym Environment

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

Featured in Robotics Weekly and Mithi's Robotics Coursework!

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.

You'll notice that there are gifs of the original SpotMicro as well a new version designed for added real world fidelity. The default branch simulates the new version, but you can work with SpotMicro in the spotmicroai branch of this repo. The new version also has a more reliable URDF, with more accurate inertial calculations.

If you don't need a Gym environment, that's okay too! env_tester.py works without RL or Gym, it 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

SRIK

D^2 Gait Modulation with Bezier Curves

I'm using this platform to validate a novel Reinforcement Learning method for locomotion by myself and my co-authors Matthew L. Elwin, Ian Abraham, and Todd D. Murphey. Instead of learning a gait from scratch, we propose using an existing scheme as a baseline over which we optimize via training. The method is called D^2 Gait Modulation with Bezier Curves. To learn more, visit our website

Training

During training, 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:

NO_FALL

What's even better, is that the same agent #149 is able to adapt to unseen commands, making high-level system integration straightforward. Here it is being teleoperated using Forward, Lateral, and Yaw commands.

UNIVERSAL

Here's an example of the new URDF being teleoperated with a trained agent on 2x higher terrain:

UNIVERSAL2

Real World Validation

Here are some experimental results where the agent is on the right.

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
  • Scipy
  • Numpy

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 Training

Go to spot_bullet/src and do ./spot_ars.py. Models will be saved every 9th episode to spot_bullet/models/. I will add some more arguments in the future to give you finer control of the heightfield mesh from the command line.

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
-gui, --GUI         Control The Robot Yourself With a GUI
-a, --AgentNum      Agent Number To Load (followed by number)

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

Citing Spot Mini Mini

@software{spotminimini2020github,
  author = {Maurice Rahme and Ian Abraham and Matthew Elwin and Todd Murphey},
  title = {SpotMiniMini: Pybullet Gym Environment for Gait Modulation with Bezier Curves},
  url = {https://github.com/moribots/spot_mini_mini},
  version = {2.1.0},
  year = {2020},
}

Credits

spot_mini_mini's People

Contributors

grassjelly avatar moribots avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spot_mini_mini's Issues

Details on PDB board production

I'm trying to reproduce the project. However I'm not that into PCB design, and while being able to understand the PDB design at a high level I am not able to fulfill some details. It would be great if you can provide a BOM for the single-power version, or if you could help me with the following questions please:

  1. in the single power version there are four slots for "resistors" -- what type and size (ohm) should I use for each resistor?
  2. if I use the servo as suggested in the list (JX CLS6336 Servo (36KG)), what is the suggested size of the capacitors? Or any between 100uF and 470 uF is fine?
  3. What are the usage of S1, S2, S3, S4 ? Are they for the hall sensor connections?
  4. It is mentioned that hall sensor slots are added on the feet, but there is no hall sensor listed on the BOM? are they still in the TODO list?

Thanks!

Controller does not move spot

Describe the bug
After launching the spot_move.launch and previously setting up the joystick controller, there is no movement even though the joy node is registering it

Expected behavior
For the robot to move as explained in the guide

Screenshots
Screenshot from 2021-06-15 18-30-03

Desktop (please complete the following information):

  • OS: Ubuntu 20.04

Reward difference paper

Hi @moribots,
I am recreating this project and building upon it for a project for my uni, yet there is an important incongruity I can't figure out.
When I run the code straight away I get an reward per step of 5.4 at the first training steps. However, in figure 6 of your paper(see attached figure) the reward is supposed to start at -2.0 and never surpass 0.5 . Could you tell me where this difference in reward is coming from?
Thanks in advance!
Leon

bezierpaper_rewards

Lay down starting pose

ocation? mini_ros\src\mini_ros\teleop.cpp

Example: Line 62 - Switch Trigger: Button A (having a different button control lay down / stand up)

Idea: Would it be possible to add another button command to direct spot to lay down (the positions are in the teensy code already - but would it be possible to transition from a standing state to a laying down state through a controller button press? (similar to the BD spot) spot mini could start laying down and stand up on controller button press.

Unable to run training

When training minispot using spot_ars.py, there are two options to train: multiprocessing or without multiprocessing.

1. If multiprocessing is used, process is frozen when ars.py is called. It is stuck at line 605, I suspect parentPipe.send() is sending data larger than buffer on computer (I have tried with a few computers to run the code). Is there an alternative way to send using multiprocessing?

2. If no multiprocessing is used, ars.py is again called. This time it is stuck at line 403, with the following error message:

_Traceback (most recent call last):
File "C:\Users\TON93824\OneDrive - Mott MacDonald\Desktop\scripts\083. dmd\spot_bullet\src\spot_ars.py", line 227, in
main()
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\spot_ars.py", line 184, in main
episode_reward, episode_timesteps = agent.train()#parallel(parentPipes)
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\ars_lib\ars.py", line 564, in train
positive_rewards[i] = self.deploy(direction="+", delta=deltas[i])
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\ars_lib\ars.py", line 407, in deploy
state, reward, done, _ = self.env.step(action)
File "../..\spotmicro\GymEnvs\spot_bezier_env.py", line 163, in step
action = self.ja # during training state have to use action[2:]
AttributeError: 'spotBezierEnv' object has no attribute 'ja'

A closer look shows that the "def pass_joint_angles" was not called under spot_bezier_env.py, thus "def step" cannot call for self.ja. I suspect the no multiprocessing training function was not complete but I cannot fix the script myself, any hint?

3. Under the "contact" folder where trained policies are stored, they do not seem to be able to be loaded during evaluation. The following error message is found:

Traceback (most recent call last):
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\spot_ars_eval.py", line 313, in
main()
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\spot_ars_eval.py", line 186, in main
agent.load(models_path + "/" + file_name + str(agent_num))
File "C:\Users\Desktop\scripts\083. dmd\spot_bullet\src\ars_lib\ars.py", line 702, in load
self.policy.theta = pickle.load(filehandle)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in range(128)

Looks like the originally generated policy files were done differently? (Maybe on a linux machine??)

Starting walking motion

First of all, thank you for providing this very nice repository! I have a question about the simulation:

After cloning the repo and installing the dependencies, I am able to start the simulation using ./env_tester.py. Using the provided sliders, I am able to change the roll, pitch, yaw etc. and the robot shows the changes in the simulation. However, I am not able to start the walking motion. Is there some specific step that I need to perform to start the walk?

Considerations for 'Learning Quadrupedal Locomotion over Challenging Terrain' Paper

Hi @moribots ,

Thank you for this fantastic effort in making this niche field open sourced. I was browsing through your source code as well as the research paper that inspired this work, and made some comparisons with more recent advancements in Deep Reinforcement Learning for robotic quadrupeds.

  1. How much effort is required to use this existing work to train another robotic quadruped of an entirely different set of URDF? For instance, how much changes do we need to do in order to train the Anymal Model C robot (URDF here)?

  2. If adapting the existing framework to accomodate other types of quadrupeds is simple, how much effort is required to update the the approach to match current approaches? For instance, the work as shown by the ETH Zurich's Robotics Systems Lab? (For one, they use Raisim while this repository is in the OpenAI Gym environment)

I am really excited about the prospect of Legged robots, and would love to invest the time to furthering the work in this repository. Looking forward to hearing from you!

Regards,
Derek

old non-functional guide

who runs this mess of links that lead nowhere??? spot mini mini unmaintained pages, old non-functional guide.

Source code filename collisions on case-insensitive filesystems

Describe the bug
Several files of this repository have same filenames ignoring cases. When cloned on Mac OS / Windows, it would cause filename collision problems. Known collisions are:

To Reproduce
run git clone on Mac OS / Windows

Expected behavior
Some of the files should be renamed to avoid collisions.

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

roslaunch mini_ros spot_move.launch exit code 127

Describe the bug
The launching of the node doesn't do anything

To Reproduce
Steps to reproduce the behavior:

  1. Get everything ready (roscore, joy node)
    2.roslaunch mini_ros spot_move.launch
  2. Nothing happens and the error pops out

Expected behavior
Control robot in simulator with joystick controller

Screenshots
jon@jon-noetic:~/catkin_ws$ roslaunch mini_ros spot_move.launch
... logging to /home/jon/.ros/log/4d0e42a6-cde7-11eb-8559-f11a37245d28/roslaunch-jon-noetic-17165.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://jon-noetic:38909/

SUMMARY

PARAMETERS

  • /rosdistro: noetic
  • /rosversion: 1.15.11
  • /spot_joy/deadzone: 0.05
  • /spot_joy/dev: /dev/input/js0
  • /spot_sm/frequency: 200.0
  • /spot_teleop/axis_angular: 0
  • /spot_teleop/axis_linear_x: 4
  • /spot_teleop/axis_linear_y: 3
  • /spot_teleop/axis_linear_z: 1
  • /spot_teleop/button_estop: 1
  • /spot_teleop/button_switch: 0
  • /spot_teleop/frequency: 200.0
  • /spot_teleop/scale_angular: 1.0
  • /spot_teleop/scale_linear: 1.0

NODES
/
spot_joy (joy/joy_node)
spot_pybullet (mini_ros/spot_pybullet_interface)
spot_sm (mini_ros/spot_sm)
spot_teleop (mini_ros/teleop_node)

ROS_MASTER_URI=http://localhost:11311

process[spot_sm-1]: started with pid [17179]
process[spot_joy-2]: started with pid [17180]
[ INFO] [1623770031.194453852]: STARTING NODE: spot_mini State Machine
process[spot_teleop-3]: started with pid [17181]
process[spot_pybullet-4]: started with pid [17186]
/usr/bin/env: ‘python’: No such file or directory
[ INFO] [1623770031.203788747]: STARTING NODE: Teleoperation
[spot_pybullet-4] process has died [pid 17186, exit code 127, cmd /home/jon/catkin_ws/src/spot_mini_mini/mini_ros/src/spot_pybullet_interface __name:=spot_pybullet __log:=/home/jon/.ros/log/4d0e42a6-cde7-11eb-8559-f11a37245d28/spot_pybullet-4.log].
log file: /home/jon/.ros/log/4d0e42a6-cde7-11eb-8559-f11a37245d28/spot_pybullet-4*.log
[ WARN] [1623770031.228110980]: Couldn't set gain on joystick force feedback: Bad file descriptor

Desktop (please complete the following information):

  • OS: Ubuntu 20.04

Non strainge forward walk

Hello!
At first, I would like to say that your project is great and well-done.
I went through the project and tried to simulate the spot:

  1. Run ./env_tester.py.
  2. Define StepLenght=0.05
    However, the spot were walking forward with small shifting in left side. I saw that you tried fix that by AutoYaw (if I understood corectly).
    Could you tell me why this problem appears? Is this problem in a BezierGait algorithm?
    I am looking forwad for your answer. Thanks.

CAD model outside of OnShape

Hello! I understand that this is no longer being developed on, but I was wondering if it might be possible to get the CAD model/URDF/etc files outside of the OnShape platform? There doesn't appear to be an easy way to download the entire OnShape project, only whatever you can see and select at-a-time.

Keyboard Teleop Support

Why not use a "param" value in ROS launch file,
to choose from Controller / Keyboard / terminal command (ros cmd_vel publisher)

The calibration code does not work

I don't understand what should I put in the calibration code for the elbow lie down and wrist lie down , I cannot understand the parameters ?
I have noted the 90 degree pwm and 0.
What should I do next?

spot_ars_eval.py is not working that URDF file can not found 'spot.urdf'.

Hi
I use 'spot_mini_mini' to my project. 'spot_mini_mini' is very nice project.
I want to use reinforcement learning to my quadruped robot.
But, When I use 'spot_ars_eval.py', I got an error message about
"spot_best\spot_2\src\spotmicro\util\pybullet_data/assets/urdf/spot.urdf' not found".

Can give a comment for me?

Information regarding usability of model

Is your feature request related to a problem? Please describe.
Not really. It's more about the missing information regarding how the spot_real code really works on the Rpi in order to implement it in other similar systems.

Describe the solution you'd like
More information on how the code works and handles the models and information.

Additional context
I’m finishing my masters degree project with spotmicroai and my idea is to communicate via ros and do Control + extract all sensor info and after reading the paper and seeing the project, I was very interested in using RL for the gait.
I’m using an ESP32 as an interface for low level control inside the robot and I’m able to comunicate via serial and/or wifi with a linux system (RPi / PC) for the heavy lifting. My goal is to use the spot_real with RL as a starting point and further down the line develope the model and extras. But I really did not get how the software runs on the RPi on your implementation. I understood that The board on spot reads and handles sensors via serial as well as handling the bidirectional communication with the motors. But I’d love to know/understand better how does the RPi handle this info and apply the trained model with RL for the gait control (I believe it’s part of the launch file) but if you could explain it a bit it would be wonderful and really appreciated. This way I could iterate on it and develope a new approach for communication that I will share and cite on the publication.

Any help is welcomed. :D

Failed to process package 'mini_ros'

Install the project...
-- Install configuration: "Release"
-- Installing: /opt/ros/melodic/_setup_util.py
-- Installing: /opt/ros/melodic/env.sh
-- Installing: /opt/ros/melodic/setup.bash
-- Installing: /opt/ros/melodic/local_setup.bash
-- Installing: /opt/ros/melodic/setup.sh
-- Installing: /opt/ros/melodic/local_setup.sh
-- Installing: /opt/ros/melodic/setup.zsh
-- Installing: /opt/ros/melodic/local_setup.zsh
-- Installing: /opt/ros/melodic/.rosinstall

  • cd /home/pi/ros_catkin_ws/src/spot_mini_mini/mini_ros

  • mkdir -p /opt/ros/melodic/lib/python2.7/dist-packages

  • /usr/bin/env PYTHONPATH=/opt/ros/melodic/lib/python2.7/dist-packages:/home/pi/ros_catkin_ws/build_isolated/mini_ros/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages CATKIN_BINARY_DIR=/home/pi/ros_catkin_ws/build_isolated/mini_ros /usr/bin/python2 /home/pi/ros_catkin_ws/src/spot_mini_mini/mini_ros/setup.py build --build-base /home/pi/ros_catkin_ws/build_isolated/mini_ros install --root=/ --install-layout=deb --prefix=/opt/ros/melodic --install-scripts=/opt/ros/melodic/bin
    running build
    running build_py
    error: package directory 'mini_bullet' does not exist
    CMake Error at catkin_generated/safe_execute_install.cmake:4 (message):

    execute_process(/home/pi/ros_catkin_ws/build_isolated/mini_ros/catkin_generated/python_distutils_install.sh)
    returned error code
    Call Stack (most recent call first):
    cmake_install.cmake:137 (include)

make: *** [Makefile:83: install] Chyba 1
<== Failed to process package 'mini_ros':
Command '['/opt/ros/melodic/env.sh', 'make', 'install']' returned non-zero exit status 2.

Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/mini_ros && /opt/ros/melodic/env.sh make install

Command failed, exiting.

Hi, can someone please help me?
there is a lot of "mini_bullet" on the github, but none refer here. who is the one I need to download to make it work?

How do I use the OpenSource Code in this Github Project?

Hello Spot Micro AI developers! I am so in love with this project and really want to build and try it for myself. Before I build it, I really wanted to have a concrete set of steps laid out for myself. While I did read the documentation which included assembly instructions and saw the video of the robot, I still don't understand the process behind uploading the different kinds of code on this page. I couldn't find assembly instructions including the code. I wanted to use the Raspberry Pi 4 and Arduino for this project. Are there any tutorials I may not have seen or any instructions on what kind of code goes to what device? Thank you so much in advance! I am a beginner at robotics as I am more of a software person!

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.