Introduction

Gravity compensation is a fundamental technique in robotics that allows a robot arm to be freely moved by hand while maintaining its position when released. This page will explain how you can create a simple gravity compensation algorithm for the SO-100 robot arm.

How Gravity Compensation Works

At its core, gravity compensation counteracts the effect of gravity on a robot’s joints. Without compensation, a robot arm would fall due to gravity when the motors are not actively holding position. With proper compensation, you can move the robot by hand, and it will stay in place when released.

Core Concept

Gravity compensation enables intuitive physical interaction with robots without requiring motor power to maintain position.

The Physics Behind It

The implementation uses the principle of inverse dynamics to calculate the torques needed to counteract gravity. Let’s break down the key components:

Implementation Details

Let’s examine key aspects needed to implement gravity compensation for the SO-100 robot arm.

PID Gains Adjustment

To make the robot arm more compliant during gravity compensation, we adjust the PID gains of the motors. The default gains are optimized for position control, but we need different gains for gravity compensation.

Tuning Note

These will depend on the motors you have, 6V or 12V. Play around with the values to find the best settings for your robot.

These are lower than the default gains, making the robot more responsive to external forces while still maintaining enough stiffness to hold position against gravity.

The Control Loop

The main gravity compensation loop needs to run at a high frequency to provide smooth motion. You should aim for at least 50 Hz to 100 Hz.

Here’s a simplified version of the loop:

  1. Read current joint positions
  2. Update the robot state in the physics simulator (Mujoco, Genesis, PyBullet, etc.)
  3. Calculate gravity torques using inverse dynamics
  4. Compute desired positions with the virtual displacement formula
  5. Send the new positions to the motors
  6. Repeat

Implementation Options

Physics Simulators:

  • Mujoco
  • Genesis
  • PyBullet

Learn more

Learn more about PyBullet for robot simulation

The Alpha Parameter

The alpha parameter is crucial for tuning the gravity compensation:

This array controls how much each joint responds to the calculated gravity torques:

  • Higher values make the joint more responsive but potentially less stable

  • Lower values make the joint more stable but potentially less responsive

Zero values mean no compensation for that joint

The values are tuned for each joint based on its mass properties and mechanical characteristics.

Mathematical Analysis

Learn more

Learn more about Inverse Dynamics in robotics

Enjoy, and Happy Coding!