sábado, 2 de noviembre de 2024

Balancing an Inverted Pendulum - Charmlab - Stanford

Balancing an Inverted Pendulum



Project team members: Brandon Briones, Michael Maffezzoli, Hallie Mikacich, Will Ortiz

The goal of this project is to implement a device that applies force and visual feedback to the user to simulate balancing an inverted pendulum on a plate. The display has a Hapkit mounted on the back wall of a box that stays firm on the table with suction cups. The Hapkit handle sticks out of the box and represents a plate that can be moved side to side to balance the pendulum. The box is paired with a visual simulation of the pendulum to provide an engaging and fun experience for users. By performing a user study, we aim to better understand the role of sight and force feedback, respectively in balancing objects.

The resulting product allows for the user to control the speed and position of the base of a simulated inverted pendulum via a 1DOF handle. The handle is supplied with force feedback that is proportional to the angle and speed of the pendulum. On demo day the device was paired with a physical inverted pendulum that users tried with a glove (to remove haptic feedback) and tried with their eyes closed (to remove visual feedback). Overall, both the display and the physical pendulum successfully conveyed information on the respective roles of haptic and visual feedback in balance.

Introduction

There were two primary motivations in this device concept. Firstly, we want to develop a game-like device that people can experience and learn from easily in a demo setting. This inverted pendulum has the ability to teach people about the dynamics of pendulums, and allow them to show off their perseverance and balance all in a short window of time. Secondly, we hope to learn something about how humans interact with their environment. This balancing task requires information about the object geometry, and this implementation allows for us to control for any combination of visual and haptic feedback, which can help us learn more about what the human relies on for balance.

There are many possible applications of this research that we are excited about. Not only could understanding what tools humans use to balance objects help in developing better robotics, but it could also provide information relevant to prosthetic arm users, and people with impaired balance. Furthermore, this platform could allow for research into types of objects humans balance well, leading to developments in ergonomics for tools used in daily tasks like cooking.

Background

Early in this course, we learned about tactile haptic devices (where your skin is simulated) as well as kinesthetic haptic devices (which gives force or motion feedback). For our project, we adapted the Hapkit, which is a kinesthetic haptic device, to focus on the role of kinesthetic haptic feedback and visual feedback in balance.

Previous research into haptic feedback for an inverted pendulum used a planar robotic manipulandum in conjunction with a mirrored display to simulate the balancing of a pendulum. The researchers conducted two experiments: one varied the height of the pendulum but kept the virtual eye focused on the top, the second varied the "eye" height but kept the pendulum dynamics the same. Franklin et al. noted the importance of visual and haptic feedback aligning and providing accurate information about the system [1]. The research group followed up on their study showing that delaying the haptic feedback can throw off the user’s ability to balance the pendulum [2].

It is possible that the importance of accurate and congruent visual and haptic feedback extends beyond balancing pendulums, to balancing ourselves. Research on stroke rehabilitation looked into how supplying haptic feedback related to the location of the patient’s center of foot affected their sense of balance. It found that haptic feedback helped rehabilitation in patients with post-stroke balance difficulties [3]. Another study found that haptic feedback improves balance control in people with Parkinson's Disease [4]. Perhaps, similarly to the pendulum, there is a time delay or visual, haptic incongruence that limits the effectiveness of this feedback if it is not done with the necessary precision.

Methods

Hardware design and implementation

To create our actuation system we utilized our hapkit to take advantage of the 1 DOF and DC motor for force feedback. However, in order for the control of the pendulum to feel closer to the original physical system, we suspended our hapkit horizontally within a box. This box is made of lasercut Acrylic and Birchwood, and is assembled with fasteners and adhesives. The box has an opening to allow for the handle to move through its entire range of motion, while keeping the handle as the only part of our system that the user needs to touch. The intention for this was to allow for ease of use and help users understand how to operate our simulation as quickly as possible. The figures below illustrate this setup.

Bill of Materials:

  • 1 Hapkit (provided)
  • 4 nut and bolt pairs ($1)
  • 1 Clear Acrylic Sheet ($4)
  • 1 Black Acrylic Sheet ($5)
  • 1 Birchwood sheet ($8)

System analysis and control

Using our hapkit, we utilized the magnetic sensor on the arduino to measure the handle position. After recording the handle position, we used 2nd order backward differentiation to determine both the handle velocity and acceleration

In order to simulate our Inverted Pendulum within Arduino, we first began with the following dynamic equations that describe an inverted pendulum on a cart. These equations were found in Advanced Dynamics & Motion Simulation For Professional Engineers and Scientists.

Starting with the second equation, we used variable parameters: mass, g, length, Izz, and the acceleration listed above to solve for angular acceleration. Then, using the equation for angular acceleration, we used 4th order Runge Kutta to determined our theta, and angular velocity.

While using this method resulted in a somewhat realistic inverted pendulum simulation, there were many approximations made along the way, and this resulted in our pendulum behaving not quite as naturally as we had hoped. After attempting many different methods of approximation for handle acceleration and angular acceleration, we determined that this original method worked the best. We then tweaked some parameters to help the pendulum look and feel more realistic. For example, the simulated pendulum would fall much slower than our physical pendulum demo, so we decided to increase mass and gravity, and decrease the length parameters until the simulation looked and felt realistic. While these parameters ended up not being representative of a physical system inherently, we determined that providing an engaging and realistic simulation took precedence. Additionally, the angular momentum of the simulated pendulum carried much longer than seemed realistic, and so we implemented a condition where the gravity parameter is greatly increased when the pendulum is close to upright, and this acted as some sort of pseudo damper which kept the pendulum from tilting over undexpectedly, and thus made it more intuitive to interact with.

We also began with our first pendulum for force, however our approximations for handle acceleration resulted in extremely noisy data, which would spike immensely and unexpectedly. Because this equation for force uses this approximation for acceleration, the feedback force would inevitably become unstable and unrealistic for the user. Because of this, we implemented a different calculation for force, which is proportional to theta and the handle velocity. This equation resulted in a more reliable and realistic force output.

Demonstration / application

For our demonstration, we first had users practice balancing a physical system (a small pool cue) to give them some intuition behind balancing an inverted pendulum. This physical demonstration also had users attempt to balance the pool cue without sight (blindfolded), and with limited haptic feedback (wearing layered gloves).

Next we had users try our simulated inverted pendulum program with force feedback turned on and off. We took their best (longest) time for each version of the simulation, and recorded the results. We also randomly changed the order for which each user tried the simulation: some starting with force feedback, and some without. The reason behind this was to try and get a grasp on how much practice had an effect on the best time results and which they thought was easier.

Results

Quantitative

Time-to-failure (and which trial came first) was recorded for each subject. 14 subjects balanced the pendulum with no feedback first, and 10 subjects balanced it with feedback first. The time-to-failure difference between the trial with feedback and the trial without was thereby calculated for subjects who had no feedback first, subjects who had feedback first, and all subjects. For each of the three sets, we constructed a box-and-whisker plot of the difference as well as a 95 percent confidence interval (attached below) for the difference's true mean. In every case, the interval included zero. Therefore, we cannot state with confidence that force feedback influences a subject's ability to balance an inverted pendulum based on these tests.

Qualitative

After each user completed both trials, we asked them about their experience and which scenario they thought was easier. Generally, users commented on how the simulation was harder than balancing the object in real life and had a steep learning curve. The difference in difficulty can be attributed to the fact that the simulation has a limited workspace, one degree of freedom, and doesn't trigger human depth perception or proprioception. As for comparing the two scenarios, some users found that no force feedback was easier and others said the opposite. Given the learning curve, users tended to perform better, and thus prefer, their second trial. Beyond this, users commented on how the simulation was engaging, fun, and a great use of the classic controls problem of an inverted pendulum.

Future Work

Using our demo as well as the physical pendulum, we overwhelmingly found visual feedback to be more important than kinesthetic haptic feedback for this balancing situation. As our background research suggested, slight time delays and imperfections in haptic feedback that make it incongruent with visual feedback can impair the display's effectiveness. Going forward it would be interesting to improve the model of the pendulum by including the mass of both the stick and ball at the end. We started to approach this using equations of motion derived from the Lagrangian.

This is our calculation of the inertia matrix for the stick, where the Izz component is what is used in the Lagrangian:

This is our calculation of the two equations of motion when the mass of the stick and ball at the end are taken into account:

Coding improvements to timing and in further refining the numerical integration could also be beneficial to the usefulness of the haptic feedback.

Furthermore, a better understanding of the proper performance of the simulation may be helpful to ensuring the realism of the output. We conducted an experiment to learn more about how the 2D inverted pendulum with a mass on top preforms in real life [6]. This could be useful as could further demonstrations with varying mass or stick length.

Acknowledgments

We would like to thank Allison Okamura, Dane Brouwer, Connor Yako, and Elizabeth Vasquez for all their help throughout the course and throughout the development of this project.

Files

Checkpoint 1 Code: Attach:pendulum_cart.pdf

Final Arduino Code: Attach:ME327FinalArduinoCode.pdf

Final Processing Code: Attach:ME327FinalProcessingCode.pdf

BOM:

Attach:ME327InvertedPendulumBOM.xlsx

Confidence Intervals and Box-and-Whisker Plots: Attach:final_stats.pdf

Code and drawings should be linked here. You should be able to upload these using the Attach command. If you aren't willing to share these data on a public site, please discuss with the instructor. Also, in this section include a link to a file with a list of major components and their approximate costs.

References

[1] Franklin S, Cesonis J, Franklin DW. Influence of Visual Feedback on the Sensorimotor Control of an Inverted Pendulum. Annu Int Conf IEEE Eng Med Biol Soc. 2018 Jul;2018:5170-5173. doi: 10.1109/EMBC.2018.8513461. PMID: 30441504. https://pubmed.ncbi.nlm.nih.gov/30441504/

[2] Franklin S, Cesonis J, Leib R, Franklin DW. Feedback Delay Changes the Control of an Inverted Pendulum. Annu Int Conf IEEE Eng Med Biol Soc. 2019 Jul;2019:1517-1520. doi: 10.1109/EMBC.2019.8856897. PMID: 31946182. https://pubmed.ncbi.nlm.nih.gov/31946182/

[3] Yasuda K, Saichi K, Kaibuki N, Harashima H, Iwata H. Haptic-based perception-empathy biofeedback system for balance rehabilitation in patients with chronic stroke: Concepts and initial feasibility study. Gait Posture. 2018 May;62:484-489. doi: 10.1016/j.gaitpost.2018.04.013. Epub 2018 Apr 14. PMID: 29677663. https://pubmed.ncbi.nlm.nih.gov/29677663/

[4] Rabin E, Chen J, Muratori L, DiFrancisco-Donoghue J, Werner WG. Haptic feedback from manual contact improves balance control in people with Parkinson's disease. Gait Posture. 2013 Jul;38(3):373-9. doi: 10.1016/j.gaitpost.2012.12.008. Epub 2013 Jan 11. PMID: 23313411; PMCID: PMC3664138. https://pubmed.ncbi.nlm.nih.gov/23313411/

[5] Mitiguy, Paul; Advanced Dynamics & Motion Simulation For Professional Engineers and Scientists https://www.motiongenesis.com/MGWebSite/MGTextbooks/TextbookAdvancedDynamicsAndMotionSimulation.html

[6] Experiment of 2D Inverted Pendulum https://youtu.be/d4GWnoVrgnA


Appendix: Project Checkpoints

Checkpoint 1

Goals:
  1. Design and manufacture a box to hold the hapkit horizontal such that the handle mimics a platform that moves laterally.
  2. Determine the dynamics
  3. Draft the Arduino code

We created a CAD assembly of our hapkit set up that will be laser-cut and assembled. This box will hold the hapkit sideways, so that the handle will be able to move from left to right. The end of the handle will be the controller for the base of the pendulum. The box will also make use of the plunger feet that come with the hapkit to help it remain stable when in use.

We determined the dynamics of the system based on an old dynamics problem from a class we took, and then re-did the problem to confirm that our equations of motion were correct. We modeled the handle as a massless cart with a position described by some arbitrary function (user input), and the pendulum as a massive particle at the end of a massless rod. We have assumed Earth gravity, but we have not yet decided on the length of the pendulum or the mass of the particle at its end.

Then, we implemented our Arduino code. First, we took advantage of the fact that precise position data is read into the Arduino via the MR sensor to find the handle's position, velocity and acceleration. Velocity was estimated using a higher-order solver, and acceleration was obtained with a simple backward Euler setup based on the velocity estimate (for now; further testing might reveal a need for higher precision). Then, we manually implemented a fourth-order Runge-Kutta solver to solve for the pendulum's angle, angular velocity, and angular acceleration. Force feedback on the user was a simple calculation based on the equations of motion, with the previously calculated values plugged in. The wiki doesn't allow for .ino extensions, so we have uploaded the current iteration of our Arduino code as a pdf.

Checkpoint 2

Goals:
  1. Cut and assemble box and fixture that holds the hapkit horizontally
  2. Implement Processing to visualize pendulum kinematics
  3. Implement force response

We lasercut the design created in checkpoint 1 and assembled it to hold our hapkit in the horizontal position. The design allows for the handle to move through its full range, from left to right. The design also keeps the tip of the handle as the only portion of the hapkit that is accessible, which allows for simple and straightforward interaction with the user.

After implementing a simple processing program, we were able to finally visualize our pendulum, which will aid in the debugging and fine-tuning process. With this visual we could assess how natural the pendulum felt just based on physical intuition on how we believe the pendulum should behave. We found that the pendulum falls much slower than a physical pendulum with the same mass, length, and gravity parameters that we input into the arduino program. Additionally, it seems as though the angular momentum carries for a much longer time period than what seems natural, and may require the addition of some damping. Tweaking the length, mass, and gravity parameters to more extreme values helped to mask some of these issues.

Attach:CP2_ProcessingCode.pdf

Force calculations for an inverted pendulum were implemented in to the arduino code. However, upon testing this force we found that the it was extremely unstable and would jolt a lot. We suspect that this issue is due to the fact that we are estimating both handle acceleration and angular acceleration using only handle position as an input, which can be extremely noisy. In order to solve this problem, future work will include either implementing a higher order equation to solve for accelerations, or implementing a force that is not directly simulated from an inverted pendulum system (IE: spring damper system).

Attach:CP2_ArduinoCode.pdf

No hay comentarios:

Publicar un comentario