Code

This page has links to a variety of small coding projects that I completed while learning some of the basic computer skills for robotics.
- Matthew Kelly

Simulation

← Lagrange mechanics

A few tutorials, written in Matlab, that demonstrate how to use the Langrange Equations to derive the equation of motion for a variety of systems, including:

← Bouncing Ball

A ball bouncing around on hilly terrain. This simple simulation is designed for learning event detection with ode45 in Matlab.

← Toppling Stick

A simulation of a stick toppling from rest. Inspired by Tad Mcgeer's 1989 paper: Wobbling, toppling, and forces of contact. My simulation is based on a finite state machine, using ode45 for integration and event detection. I used this simulation to study the effects of coefficient of friction and moment of inertia; the results are discussed here.

← Three masses

A system of three point masses in 2D. The center mass is connected to the other two with arbitrary force and torque actuators. This is the basis for another simple model of walking: a point mass at each foot, and at the hip. The simulation supports many different contact configurations, as shown in this simple test animation.

Trajectory Optimization

← TrajOpt - Trajectory Optimization Library (Matlab)

I wrote a trajectory optimization library for Matlab, as a way to collect many of the things that I've learned about trajectory optimization. In particular, I tried to make the code readable, and I've also made it easy to compare different transcription methods. For example, it makes it easier to understand the trade-offs between multiple shooting and collocation, or whether it is worth it to use a high-order method.

← Double Pendulum Walker

This code uses GPOPS to find an optimal walking trajectory for a double pendulum model of walking.

← Cart-Pole Swing-Up

Solves the swing-up problem for pendulum handing from a cart. There is a motor in the cart, but the pendulum hangs free. I solve the problem using three transcription algorithms: Multiple shooting, Orthogonal Collocation, and GPOPS. The differences between these methods are discussed here.

Miscellaneous

← Dynamic Programming: Pendulum

Finds an optimal policy for an inverted pendulum, by converting the continuous system to a Markov Decision Process (MDP) and solving the Bellman equation using value iteration.

← Tractor Trailer Controller

I wrote this simulation for my Q-exam presentation . It has partial sensing of its state using noisy sensors and control of the steering angle and travel speed (both of which were bounded). The states is estimated using an extended Kalman filer (EKF) and then controlled using a discrete linear quadratic regulator (dLQ), linearized about the current state estimate.

Animations: One , Two , Three

← LQR Trajectory Tracking

A tutorial for using time-varying LQR to stabilize a non-linear trajectory. The code compares the time-varying gains to the infinite horizon gains. It also computes an approximation of the reachable set, using two different methods.

← Chebyshev Polynomials

A small library of functions that use Chebyshev polynomials for function approximation and solving differential equations. These functions are also used in my orthogonal collocation trajectory optimization program. The background methematics for this library are largely taken from a book by Lloyd Trefethen: Approximation Theory and Approximation Practice.

← CMAES Demo

This code uses Covariance Matrix Adaptation Evolutionary Strategy (CMAES) to solve for the gains in a simple non-linear controller.

← Function Smoothing

This code is used to create smooth versions of commonly used discontinuous functions (max,min,abs,ramp,clamp...). There are two methods for smoothing that are used: exponential, and polynomial.

Java Libraries

← Simple GUI Classes

This package contains a few functions for making simple 2D scientific plots and animations based on the standard java.awt and java.swing packages. It also includes some code for getting the frame-rate of an animation correct, as well as linking buttons to parameters in an animation.

← DynamicalSystems and Control

A few functions that I've used in my Java simulation libraries for doing simulations of walking robots. Most code is not posted, but I have included a few utility classes, such as a Butterworth filter.

← Examples

A few executable Java classes that demonstrate the use of the above packages, particularily for plotting and animation.

← Games

A place to put simple Java games. So far I've only written one: Snake.

Website

← Website

The source for this website is in GitHub, including all of the Javascript that runs the interactive tutorials.