upkie 6.1.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
upkie::cpp::observers::WheelContact Class Reference

Observe contact between a given wheel and the floor. More...

#include <WheelContact.h>

Classes

struct  Parameters
 Observer parameters. More...
 

Public Member Functions

 WheelContact (const Parameters &params)
 Initialize observer. More...
 
void observe (const double torque, const double velocity, const double dt) noexcept
 Process a new observation. More...
 
double abs_acceleration () const noexcept
 Low-pass filtered absolute wheel acceleration, in [rad] / [s]²
 
double abs_torque () const noexcept
 Low-pass filtered absolute wheel torque, in [N m].
 
bool contact () const noexcept
 Current contact state.
 
double inertia () const noexcept
 Apparent inertia I = |torque| / |acceleration| at the wheel.
 
void reset_contact () noexcept
 Reset contact to false.
 

Detailed Description

Observe contact between a given wheel and the floor.

We use an acceleration-from-torque simple linear regressor with no affine term and online updates. There is a quick intro to the math in the following post on simple linear regression with online updates. The output of this regressor is an "inertia" (torque over acceleration slope) that is low during contact and large in the air (as then the wheel needs little torque to spin freely).

The observer is made more reliable by three hacks post-processing stages:

  1. Max-passthrough filtering: We further filter the output inertia by a max-passthrough, to detect contact loss fast, which otherwise decays exponentially, so that we tend to assume contact remains if there is no contact loss for a while.
  2. Touchdown and liftoff hysteresis: Filtering aside, the other memory in this observer comes from hysteresis. Contact is detected as soon as the contact inertia goes below the configured touchdown inertia, and lost when it spikes above the liftoff inertia. This allows a gray band of variations while the robot moves around in contact.
  3. No decision when acceleration or torque is low: There is a second hysteresis around low filtered accelerations or low filtered torques. If filtered values are low then real values have been zero for a while, which is inconclusive: the robot could be standing perfectly upright rather than having lost contact. (Most likely, if it loses contact, these values won't stay zero for long anyway.) When this happens we just keep the memorized contact state and wait for more exciting data.

Constructor & Destructor Documentation

◆ WheelContact()

upkie::cpp::observers::WheelContact::WheelContact ( const Parameters params)
explicit

Initialize observer.

Parameters
[in]paramsObserver parameters.

Member Function Documentation

◆ observe()

void upkie::cpp::observers::WheelContact::observe ( const double  torque,
const double  velocity,
const double  dt 
)
noexcept

Process a new observation.

Parameters
[in]torqueNew torque observation.
[in]velocityNew velocity observation.
[in]dtDuration in seconds since last observation.

The documentation for this class was generated from the following files: