# Oscillations after rotating

**URL:** <https://xrp.discourse.group/t/oscillations-after-rotating/194>\
**Category:** Python programming\
**Created:** [December 14, 2023, 1:43pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194 "2023-12-14T13:43:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TFossDK](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@TFossDK](https://xrp.discourse.group/u/TFossDK)\
**Post date:** [December 14, 2023, 1:43pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/1 "2023-12-14T13:43:01Z")

</div>

I’ve been working on putting together a program that draws out a logo and I’m running into some interesting things. More specifically, I’m having issues where the XRP will randomly oscillate after completing a turn for 10 or so seconds before continuing on. It doesn’t happen at the same time every time I run the same code. Any ideas what would be causing this? I’m guessing it has to do with the PID settings, so i may start tweaking that a bit first, but I’d appreciate any other ideas you may have.

![ezgif.com-optimize (2)](https://canada1.discourse-cdn.com/flex011/uploads/xrp/original/1X/105169d2e642bcc194da09bfe9dad66c0e71dbe6.gif)

---

<div class="post-metadata">

**Author:** ![SCSpaeth](https://yyz1.discourse-cdn.com/flex011/user_avatar/xrp.discourse.group/scspaeth/32/90_2.png) [@SCSpaeth](https://xrp.discourse.group/u/SCSpaeth)\
**Post date:** [December 14, 2023, 2:56pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/2 "2023-12-14T14:56:27Z")

</div>

Sorry, I can’t help answer your question. But I really appreciate how your video shows how the marker fits in the holder and is free to move and rotate as the XRP moves! Thanks for sharing.

---

<div class="post-metadata">

**Author:** ![SparkFro](https://yyz1.discourse-cdn.com/flex011/user_avatar/xrp.discourse.group/sparkfro/32/12_2.png) [@SparkFro](https://xrp.discourse.group/u/SparkFro)\
**Post date:** [December 14, 2023, 4:41pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/3 "2023-12-14T16:41:37Z")

</div>

I’ve also seen this behavior sometimes, seems like the PID controller isn’t finishing when it should. I wonder if reducing the PID controller’s `min_output` would help?

> <https://github.com/Open-STEM/XRP_MicroPython/blob/9b2770197de2abe13d4c61bcddcb6b2451aa7c12/XRPLib/differential_drive.py#L241-L251>

0.35 seem high to me, I think something closer to 0.2 might do better. @TFossDK want to give that a try?

---

<div class="post-metadata">

**Author:** ![TFossDK](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@TFossDK](https://xrp.discourse.group/u/TFossDK)\
**Post date:** [December 18, 2023, 8:58pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/4 "2023-12-18T20:58:26Z")

</div>

So far that has seemed to fix the issue. If it pops up again i’ll reach out. Thanks @SparkFro

---

<div class="post-metadata">

**Author:** ![SparkFro](https://yyz1.discourse-cdn.com/flex011/user_avatar/xrp.discourse.group/sparkfro/32/12_2.png) [@SparkFro](https://xrp.discourse.group/u/SparkFro)\
**Post date:** [December 18, 2023, 9:26pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/5 "2023-12-18T21:26:07Z")

</div>

Sure thing!

@k.siegall how would you feel about officially incorporating this change in XRPLib?

---

<div class="post-metadata">

**Author:** ![k.siegall](https://avatars.discourse-cdn.com/v4/letter/k/ad7895/32.png) [@k.siegall](https://xrp.discourse.group/u/k.siegall)\
**Post date:** [December 21, 2023, 10:17pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/6 "2023-12-21T22:17:41Z")

</div>

Yea I can change that in the library - particular tuning values are always a little tedious but you’re definitely right that 0.35 as a minimum is a little large

---

<div class="post-metadata">

**Author:** ![Debbie386](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Debbie386](https://xrp.discourse.group/u/Debbie386)\
**Post date:** [January 10, 2024, 5:34pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/7 "2024-01-10T17:34:24Z")

</div>

I’m seeing the same jittery problem today. I just reloaded the python dev environment  
(switching back from the WPI/Java environment using [this](https://xrp.discourse.group/t/revert-xrp-back-to-factory-settings/127/2) method) and the section of differential\_drive quoted above looks like:

```auto
        if main_controller is None:
            main_controller = PID(
                kp = 0.1,
                ki = 0.04,
                kd = 0.04,
                min_output = 0.3,
                max_output = max_effort,
                max_integral = 10,
                tolerance = 0.25,
                tolerance_count = 3,
            )

```

And that’s completely different from what’s in the file linked above.  
Did I end up with the wrong version of the library?

---

<div class="post-metadata">

**Author:** ![bamiller](https://yyz1.discourse-cdn.com/flex011/user_avatar/xrp.discourse.group/bamiller/32/5_2.png) [@bamiller](https://xrp.discourse.group/u/bamiller)\
**Post date:** [February 4, 2024, 10:34pm UTC](https://xrp.discourse.group/t/oscillations-after-rotating/194/8 "2024-02-04T22:34:02Z")

</div>

Those values are for the main\_controller for the Straight function, not the Turn function. They look almost identical.
