Advice on reducing Simulation vs. Hardware gap in Rotary Inverted Pendulum

0 replies · 262 views
Pipsqueakalchemist
Messages
142
Reaction score
20
TL;DR
Rotary Inverted Pendulum with LQR controller, trying to improve Simulation to be more realistic and match hardware.
So I'm trying to implement a LQR control on a Rotary Inverted Pendulum. I derived the dynamics and created a Simulink model and it works perfectly in simulation. I'm trying to close the sim to real gap. My hardware component is the follwing, Nema17 with quadrature encoder mounted, AS5600 for pendulum readings, a TMC2208 to drive the motor, and a ESP32 Devkit V1 as the microcontroller.

I performed some step input, ramp input, periodic input on Nema17 (without pendulum readings). I basically modelled the relation between commanded motor velocity in code with Accelstepper library and the actual motor velocity measured by taking dirty derivatives of the encoder readings as a 2nd order system. I used the step input data and Matlab's system identification app to approximate the model and compared it with the ramp and periodic and it seemed accurate enough.

The next steps I plan to do is to make the Simulink model more realistic is

  • add my dirty derivative computation for the velocities into the Simulink (before I was reading the true velocity from joint block)
  • compute step,ramp,periodic with pendulum readings, and use Simulink parameter estimation to model the hardware dynamics
Is this a valid plan? I know my hardware is capable since I see other people have successfully implemented LQR on Rotary Inverted Pendulum with similar/exact hardware. This is my first project implementing a model controller like LQR on hardware and so far the Simulation to hardware disparity has been a real learning curve. I would appreciate any feedback and criticism on how other people make the simulation more hardware realistic.