How to Use the PidFilter for WheeledChassis Steering?

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

User avatar
WizGeek
New User
Posts: 19
Joined: Sun Sep 08, 2013 9:07 pm
Location: Tampa Bay Area

How to Use the PidFilter for WheeledChassis Steering?

Postby WizGeek » Wed Aug 30, 2017 10:04 pm

I see there's a new PidFilter created by Aswin Bouwmeester. Thanks!

What's the proper way to use a PidFilter for an EV3ColorSensor (port 4) to steer a two-wheeled WheeledChassis (ports A & D)?

What insight can be shared for tuning the {lowerBound, upperBound, proportional, integral, derivative, and setpoint} when the EV3ColorSensor RedMode sample provider is giving 0.32 for white and 0.03 for black?
WizGeek
"No-no, Fizzgig, you stay here." :cry:

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: How to Use the PidFilter for WheeledChassis Steering?

Postby gloomyandy » Wed Aug 30, 2017 10:20 pm

Although this code does not use the PID filter, it does use a PID algorithm so it may give you some ideas for how to use the light sensor and the chassis together.

https://lejosnews.wordpress.com/2015/05 ... ts-part-1/

This code also provides an interesting example of why having a standard filter may not always be a good idea!
leJOS news https://lejosnews.wordpress.com/

User avatar
WizGeek
New User
Posts: 19
Joined: Sun Sep 08, 2013 9:07 pm
Location: Tampa Bay Area

Re: How to Use the PidFilter for WheeledChassis Steering?

Postby WizGeek » Thu Aug 31, 2017 1:59 am

Thanks for the link. I'd like to use the code because of its simplicity, but there's still the question of values for the constants and fields.

Can you share the entire program, so I can get a feel for what values were used in the accompanying video?:

Code: Select all

    private static final int MAX_STEER = 0;  //?
    private static final int LOOP_TIME = 0;  //?
 
    private float P; //=?
    private float targetSpeed; //=?
    private float curSpeed; //=?
    private float I; //=?
    private float totalError; //=?
    private float prevError; //=?
    private int acceleration; //=?


I'll tweak it from there.
WizGeek
"No-no, Fizzgig, you stay here." :cry:

Aswin
leJOS Team Member
Posts: 310
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands
Contact:

Re: How to Use the PidFilter for WheeledChassis Steering?

Postby Aswin » Fri Sep 01, 2017 2:04 pm

Hi,

I would start with normalizing the signal from the sensor to a scale between 0 (dark) and 1 or 100 (light) before feeding it to the PID filter. You can do this using the LinearCalibrationFilter. This way you can feed the PID filter a constant range of values regardless of the light conditions. It will result in a more robust program.

The output of the PID filter (the process variable) can be used to set the angular speed of the Chassis.

Assuming you normilized the sample from the light sensor the setpoint should be set to .5 (or 50). The upper and lower bounds should be set to the maximum angular speed you want the robot to have.

As to the PID parameters. For me this always is a process of trial and error. You could keep track of the sum of the absolute values of the process variable to monitor the fitness of your filter. Assuming that a lower value will indicate a better filter.

The PID filter has hardly been tested. Any feedback on the filter will be much appreciated.

Aswin
My NXT blog: http://nxttime.wordpress.com/

User avatar
WizGeek
New User
Posts: 19
Joined: Sun Sep 08, 2013 9:07 pm
Location: Tampa Bay Area

Re: How to Use the PidFilter for WheeledChassis Steering?

Postby WizGeek » Tue Sep 05, 2017 8:08 pm

Andy (and maybe Aswin),

One last question regarding the code from https://lejosnews.wordpress.com/2015/05 ... ts-part-1/ :
Assuming curSpeed initially is set to targetSpeed before the PID thread is kicked off, when would curSpeed not equal targetSpeed as tested at line 20?
WizGeek
"No-no, Fizzgig, you stay here." :cry:

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: How to Use the PidFilter for WheeledChassis Steering?

Postby gloomyandy » Tue Sep 05, 2017 9:08 pm

targetSpeed can be adjusted via a method in the class, the PID code runs on a separate thread. targetSpeed can be adjusted in this case by a method called from the code that communicates with the PC based based control program (this code runs on another thread) in response to user input. But in a simple program you might have code in the main thread that first creates the PID class and other components and then starts the robot moving by calling the method to set the target speed.
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests