Skip to content

PID demo revised#49

Closed
kngwyu wants to merge 2 commits intooist:mainfrom
kngwyu:qrdemo-pid
Closed

PID demo revised#49
kngwyu wants to merge 2 commits intooist:mainfrom
kngwyu:qrdemo-pid

Conversation

@kngwyu
Copy link
Copy Markdown
Collaborator

@kngwyu kngwyu commented Sep 6, 2025

No description provided.

<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="Theme.PIDBalancer" parent="Theme.Material3.DayNight.NoActionBar">
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually very important to make the whole things work

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why this is important. It looks like you just changed the layout theme.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the slider only exists in the material theme, as far as I know.

// error betweeen actual and desired wheel speed (default 0)
double e_w = 0.0 - speedL;
Log.v(TAG, "speedL:" + speedL);
Log.v(TAG, "speedL: " + speedL + ", deg: " + thetaDeg);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@topherbuckley Can I ask what is the unit of speed here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR

It appears it is in mm/s, but does not account for slippage, or other non-linear effects. This is linear speed not angular. The radius of the wheel is accounted for.

Details

I don't recall off the top of my head, but looking here it is hardcoded to the value wheelSpeedExpAvgL

which you can follow to here

keep following tohere

Following to here

It appears it is in mm/s. I believe the division by 1000000000f is to convert nanoseconds to seconds, which is what is output from whatever method I was using for getting the timestamps. See more info at the top definitions of the wheelData class.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note I'm only accounting for a single (Left) wheel in this, so any drift between wheels is not accounted for. And finally noting that this is one of several "software" metrics I made for the speed. You can also try setting this to wheelSpeedBufferedL or adjusting the exponential filter or buffer size using the builders here if the control signal is not stable. I recall tuning this a fair bit though so I hope the default values work well enough. (I haven't checked this in several years though so I could be wrong). Ideally you use the builders so you can tune the values for whatever your application is (e.g. PID balancer). The hardcoded values, I hope are fine for most controllers, which is why I set them as the defaults.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if they still work or not, but I was using the scripts in utils to plot these kinds of data streams in real time to check for stability and whatnot.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm gonna try the buffered one with default params anyways

Copy link
Copy Markdown
Collaborator

@topherbuckley topherbuckley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The big issue with this PR is that you have a rename of a directory in the same commit as changes to the files. Apparently git got confused and thinks there are a bunch of new files, when there are not. See my comment on apps/pidBalancer/src/main/java/jp/oist/abcvlib/pidbalancer/MainActivity.java for potential workarounds.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR is labeled as PID demo revised. Can you limit your changes to the PID demo then? I'm happy to take a look at these updates to the QR code demos if you think they are needed, but in a separate PR please.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this showing as a new file? Didn't it exist before? I'd like to see the diff if so. Normally git should detect a file move like this. Not sure what happened.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now. You changed the path from pidbalancer to pidBalancer. Can you:

  1. Create a new branch based on main
  2. Change the directory to pidBalancer without any other changes.
  3. Commit to new branch
  4. Rebase this branch onto that new branch.
  5. Update the PR to reference the new branch

That should allow us to see the diff of what was actually updated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that doesn't work, just a PR with the directory change and nothing else, then we can merge that to main and revist this PR. Otherwise everything looks like new additions and your updates are indiscernible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'm gonna re-organize the PR

// error betweeen actual and desired wheel speed (default 0)
double e_w = 0.0 - speedL;
Log.v(TAG, "speedL:" + speedL);
Log.v(TAG, "speedL: " + speedL + ", deg: " + thetaDeg);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR

It appears it is in mm/s, but does not account for slippage, or other non-linear effects. This is linear speed not angular. The radius of the wheel is accounted for.

Details

I don't recall off the top of my head, but looking here it is hardcoded to the value wheelSpeedExpAvgL

which you can follow to here

keep following tohere

Following to here

It appears it is in mm/s. I believe the division by 1000000000f is to convert nanoseconds to seconds, which is what is output from whatever method I was using for getting the timestamps. See more info at the top definitions of the wheelData class.

// error betweeen actual and desired wheel speed (default 0)
double e_w = 0.0 - speedL;
Log.v(TAG, "speedL:" + speedL);
Log.v(TAG, "speedL: " + speedL + ", deg: " + thetaDeg);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note I'm only accounting for a single (Left) wheel in this, so any drift between wheels is not accounted for. And finally noting that this is one of several "software" metrics I made for the speed. You can also try setting this to wheelSpeedBufferedL or adjusting the exponential filter or buffer size using the builders here if the control signal is not stable. I recall tuning this a fair bit though so I hope the default values work well enough. (I haven't checked this in several years though so I could be wrong). Ideally you use the builders so you can tune the values for whatever your application is (e.g. PID balancer). The hardcoded values, I hope are fine for most controllers, which is why I set them as the defaults.

// error betweeen actual and desired wheel speed (default 0)
double e_w = 0.0 - speedL;
Log.v(TAG, "speedL:" + speedL);
Log.v(TAG, "speedL: " + speedL + ", deg: " + thetaDeg);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if they still work or not, but I was using the scripts in utils to plot these kinds of data streams in real time to check for stability and whatnot.

@topherbuckley
Copy link
Copy Markdown
Collaborator

Also be sure if passes the build test (it currently does not) before merging to main. You are free to merge it to a dev branch in the meantime if you want it on the oist repo rather than your fork some reason though.

@kngwyu kngwyu closed this Sep 8, 2025
@kngwyu
Copy link
Copy Markdown
Collaborator Author

kngwyu commented Sep 8, 2025

Plz understand that I have very limited time for this 😢
I need to write thesis. But anyways I'm gonna re-organize everything

@kngwyu
Copy link
Copy Markdown
Collaborator Author

kngwyu commented Sep 8, 2025

I'm a bit urgent to prepare demo so I'm gonna keep this branch as is, but I'll prepare PRs that picks up a related chunk of changes in a stream-lined way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants