Git Product home page Git Product logo

stanfordquadruped's Introduction

Stanford Quadruped

Overview

This repository hosts the code for Stanford Pupper and Stanford Woofer, Raspberry Pi-based quadruped robots that can trot, walk, and jump.

Pupper CC Max Morse

Video of pupper in action: https://youtu.be/NIjodHA78UE

Project page: https://stanfordstudentrobotics.org/pupper

Documentation & build guide: https://pupper.readthedocs.io/en/latest/

How it works

Overview diagram The main program is run_robot.py which is located in this directory. The robot code is run as a loop, with a joystick interface, a controller, and a hardware interface orchestrating the behavior.

The joystick interface is responsible for reading joystick inputs from a UDP socket and converting them into a generic robot command type. A separate program, joystick.py, publishes these UDP messages, and is responsible for reading inputs from the PS4 controller over bluetooth. The controller does the bulk of the work, switching between states (trot, walk, rest, etc) and generating servo position targets. A detailed model of the controller is shown below. The third component of the code, the hardware interface, converts the position targets from the controller into PWM duty cycles, which it then passes to a Python binding to pigpiod, which then generates PWM signals in software and sends these signals to the motors attached to the Raspberry Pi. Controller diagram This diagram shows a breakdown of the robot controller. Inside, you can see four primary components: a gait scheduler (also called gait controller), a stance controller, a swing controller, and an inverse kinematics model.

The gait scheduler is responsible for planning which feet should be on the ground (stance) and which should be moving forward to the next step (swing) at any given time. In a trot for example, the diagonal pairs of legs move in sync and take turns between stance and swing. As shown in the diagram, the gait scheduler can be thought of as a conductor for each leg, switching it between stance and swing as time progresses.

The stance controller controls the feet on the ground, and is actually quite simple. It looks at the desired robot velocity, and then generates a body-relative target velocity for these stance feet that is in the opposite direction as the desired velocity. It also incorporates turning, in which case it rotates the feet relative to the body in the opposite direction as the desired body rotation.

The swing controller picks up the feet that just finished their stance phase, and brings them to their next touchdown location. The touchdown locations are selected so that the foot moves the same distance forward in swing as it does backwards in stance. For example, if in stance phase the feet move backwards at -0.4m/s (to achieve a body velocity of +0.4m/s) and the stance phase is 0.5 seconds long, then we know the feet will have moved backwards -0.20m. The swing controller will then move the feet forwards 0.20m to put the foot back in its starting place. You can imagine that if the swing controller only put the leg forward 0.15m, then every step the foot would lag more and more behind the body by -0.05m.

Both the stance and swing controllers generate target positions for the feet in cartesian coordinates relative the body center of mass. It's convenient to work in cartesian coordinates for the stance and swing planning, but we now need to convert them to motor angles. This is done by using an inverse kinematics model, which maps between cartesian body coordinates and motor angles. These motor angles, also called joint angles, are then populated into the state variable and returned by the model.

How to Build Pupper

Main documentation: https://pupper.readthedocs.io/en/latest/

You can find the bill of materials, pre-made kit purchasing options, assembly instructions, software installation, etc at this website.

Help

stanfordquadruped's People

Contributors

crazyaz avatar mark-bowers avatar nate711 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  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

stanfordquadruped's Issues

Simulated Pupper looks like it is stepping on an invisible object

When the Pupper simulator (sim branch) is run, and one looks at the robot from the side view, one can see that the physics are a bit wonky for the front legs. It looks like it is stepping on some invisible object over and over. I am not sure what causes this, my first thought was that the inertia tensor might be off. But, after playing with that a bit I don't think that is the case.

Abnormal process about pwm_to_duty_cycle

Hello,
Sometimes, I can get the abnormal return from functions "pwm_to_duty_cycle" in the file HardwareInterface.py.
It's OK after change from
return int(pulsewidth_micros / 1e6 * pwm_params.freq * pwm_params.range)
to
pulsewidth_micros = int(pulsewidth_micros / 1e6 * pwm_params.freq * pwm_params.range)
if np.isnan(pulsewidth_micros):
return 0
return int(np.clip(pulsewidth_micros, 0, 4096))

Please double confirm whether the change point is OK, thanks!
Best,
Afreez

install.sh error

pi@raspberrypi(rw):~/StanfordQuadruped$ sudo bash install.sh
Reading package lists... Done
Building dependency tree
Reading state information... Done
libatlas-base-dev is already the newest version (3.10.3-8+rpi1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
install.sh: line 2: pip3: command not found
install.sh: line 3: pip: command not found
sudo: pip: command not found
install.sh: line 7: git: command not found
install.sh: line 8: cd: PupperCommand: No such file or directory
bash: install.sh: No such file or directory
install.sh: line 12: git: command not found
install.sh: line 13: cd: PS4Joystick: No such file or directory
bash: install.sh: No such file or directory
Failed to enable unit: Unit file joystick.service does not exist.
--2019-02-14 18:30:30-- https://github.com/joan2937/pigpio/archive/v74.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
ERROR: The certificate of ‘github.com’ is not trusted.
ERROR: The certificate of ‘github.com’ is not yet activated.
The certificate has not yet been activated
unzip: cannot find or open v74.zip, v74.zip.zip or v74.zip.ZIP.
install.sh: line 20: cd: pigpio-74: No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
install.sh: line 25: cd: StanfordQuadruped: No such file or directory
ln: failed to create symbolic link '/etc/systemd/system/robot.service': File exists
Failed to enable unit: Unit file robot.service does not exist.
Failed to start robot.service: Unit robot.service not found.

Questions about vision sensors

I'm sorry I didn't find any descriptions of vision sensors in the Puppet doc. And are there any vision sensors in the Puppet?
If not, can we attach any vision sensors (or depth sensors, etc.) to the Puppet, and thus they can "see" the world?

IMU use / not use

Hi,

I see IMU code in here but you mentioned you didn't seem to think it helped much. Can you detail that here (publicly for others in the future)? It seems as pupper and derivatives of work of it, an IMU would be necessary for feedback on achieving target poses in the absence of other external sensing. Maybe also for future work in stabilization.

How to activate the robot after calibration.

image
image

I am able to calibrate the servo. I am using RPI4 normal raspian OS, not the lite version. When I start the robot service I get this. The controller is connected and the light color even changes but the robot does not work. Servos also do not active. What am I doing wrong. I have attached the screenshot.

Add a license

It seems MIT license or similar would be appropriate here.

ps4

my ps4 cannot bind to raspberry ,its just double flashes and then the flashing lights go out.
anyone can help me
thanks a lot

Inverse Kinematics

What is the coordinate system of pupper?What is the sequence of motor control?

joystick.service

Can not find joystick.service file, can this me uploaded.

Thank you

Need update raspbian buster lite to a new version

Hello,
I bought some Raspberry Pi 4 boards, but can not boot up them using 2019-09-26-raspbian-buster-lite.img, its version is too old, I tried 2020-02-13-raspbian-buster-lite.img, it's OK.
I also tried 2021-01-11-raspios-buster-armhf-lite.img, and found ssh speed is very slow, so now I use 2020-02-13 version, and have not found any issues.
You can find the image versions at the below link,
https://downloads.raspberrypi.org/raspbian_lite/images/
Please help to double confirm,thanks!
Best,
Afreez

Inverse Kinematic for a single leg

Hi,
I'm trying to create a small robot which has the same disposition of servos.
I'm struggling with the 3DOF IK (2d works), so I tried to implement yours (for now with javascript for testing).
I transpiled your Python code to Javascript, created a simple leg simulation in Three.js, and i tried to call you function leg_explicit_inverse_kinematics with custom x,y,z values :
i changed
(x, y, z) = r_body_foot
to
x=... y=..., z=...

It outputs me 3 angles, but when I put them in my leg simulation, it goes to a wrong x,y,z location.

My Parameters :

ABDUCTION_OFFSET = 4
LEG_L1 = 9.2
LEG_L2 = 10

--> the simulation : you can see at the bottom, I call pupperIk(19.2, 0, 4); which should place the arm straight, but it outputs : [98.11, -81.89, -89.99] which put my feet to the wrong location (obviously).

--> My implementation of you IK in Js is correct : i have compared my js result to you python results.

--> does it have something to do with the r_body_foot variable ?

What I would like to know, is how to use your formula to do IK of one leg independently of any other legs (the coxa being the origin ?) ?

Thank you :)

robot_leg_schema

circuit diagram!

Anyone please provide me a circuit diagram , which motor will connect which pin of raspberry pi ,which pin will connect the IMU . I am super confused.

Inconsistent naming / function name typo

Hello,

Most instances are correct, but sometimes "position" is spelled "postion" in the repository. I noticed it because I make the same typo often myself :) Right now it mostly just makes the naming inconsistent. It's not really a problem, but I thought I would point it out.

self.udp_publisher.send ConnectionRefusedError on second call

self.udp_publisher.send ConnectionRefusedError on second call
need to restart run_robot.py

pi@raspberrypi:~ $ sudo systemctl status robot
● robot.service - Robot control service
Loaded: loaded (/home/pi/StanfordQuadruped/robot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-12-29 13:48:23 GMT; 4min 22s ago
Process: 343 ExecStartPre=/usr/bin/sudo pigpiod (code=exited, status=0/SUCCESS)
Process: 412 ExecStart=/usr/bin/python3 /home/pi/StanfordQuadruped/run_robot.py (code=exited, status=1/FAILURE)
Main PID: 412 (code=exited, status=1/FAILURE)

Dec 29 13:48:13 raspberrypi python3[412]: joystick_interface.set_color(config.ps4_deactivated_color)
Dec 29 13:48:13 raspberrypi python3[412]: File "/home/pi/StanfordQuadruped/src/JoystickInterface.py", line 94, in set_color
Dec 29 13:48:13 raspberrypi python3[412]: self.udp_publisher.send(joystick_msg)
Dec 29 13:48:13 raspberrypi python3[412]: File "/usr/local/lib/python3.7/dist-packages/UDPComms.py", line 53, in send
Dec 29 13:48:13 raspberrypi python3[412]: self.sock.send(msg)
Dec 29 13:48:13 raspberrypi python3[412]: ConnectionRefusedError: [Errno 111] Connection refused
Dec 29 13:48:13 raspberrypi systemd[1]: robot.service: Main process exited, code=exited, status=1/FAILURE
Dec 29 13:48:23 raspberrypi systemd[1]: robot.service: State 'stop-sigterm' timed out. Killing.
Dec 29 13:48:23 raspberrypi systemd[1]: robot.service: Killing process 410 (pigpiod) with signal SIGKILL.
Dec 29 13:48:23 raspberrypi systemd[1]: robot.service: Failed with result 'exit-code'.

joystick.service error

Both joystick.service and robot.service are active, but an error occurred while connecting the PS4 to the Pupper.

The specific questions are as follows:

pi@raspberrypi(rw):~$ sudo systemctl status joystick.service
● joystick.service - Pupper Joystick service
Loaded: loaded (/boot/appliance/home/pi/PupperCommand/joystick.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2019-02-14 10:17:57 GMT; 78ms ago
Process: 1173 ExecStart=/usr/bin/python3 /home/pi/PupperCommand/joystick.py (code=exited, status=1/FAILURE)
Main PID: 1173 (code=exited, status=1/FAILURE)

Thank you!

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.