OCCRA
Go to Post PS: Please use the default font for postings, it is so much easier to read. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 06-22-2018, 12:01 PM
deslusionary's Avatar
deslusionary deslusionary is offline
easily impressed by fancy acronyms
AKA: Christopher Tinker
FRC #7093 (Veritas Valiants)
Team Role: Programmer
 
Join Date: Mar 2018
Rookie Year: 2018
Location: Austin TX
Posts: 121
deslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant futuredeslusionary has a brilliant future
Re: Pathfinder returning infinity?

Quote:
Originally Posted by jdao View Post
Another note about making paths with smaller periods: Although it may not take a lot of time to process on the robot, it will take a lot of time processing off the robot.... where our team was able to rapidly iterate our autos by running them up to 15 times in 10 minutes, whereas most other teams were only doing a handful in that same time period..
What techniques did your team use to cut down on path generation time?? Are you estimating the paths with arcs, like 254?

Thanks
Reply With Quote
  #17   Spotlight this post!  
Unread 06-23-2018, 05:45 PM
jdao jdao is offline
Registered User
AKA: Jonathan Dao
FRC #4201 (Vitruvian Bots)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: United States
Posts: 23
jdao will become famous soon enough
Re: Pathfinder returning infinity?

Quote:
Originally Posted by deslusionary View Post
What techniques did your team use to cut down on path generation time?? Are you estimating the paths with arcs, like 254?
Most of our work this year was guess-and-check, since this was our first year working with any type of implementation of motion profiling. We first estimated the paths that we wanted to run by defining points on the field through measurements and then our first pass was to throw them into Vannaka's Motion Profile Generator as a sanity check to ensure the paths were valid.

The real speed improvements came from writing our own separate PathfinderGen Java project that would generate the paths. Once you have defined your paths and the parameters you can use to reliably follow it, its just a matter of doing small adjustments, which was a lot easier to do in a bare-bones Java project. An improvement I'd like to make to this is for it to automatically ignore generating unchanged paths so that we don't have to manually comment/uncomment the paths we're not working/working on, as doing a full pass on every single path takes a long time.

We then used WinSCP with it's auto sync feature to sync the generated paths after PathfinderGen creates them to avoid manually copying the files over. One thing about this is that WinSCP can get a little buggy once you loose connection to your robot and may not actually sync properly, so manually resetting the connection every time you connect to the robot is a must.

Overall, this process is fast enough where we've basically regenerated a modified path and uploaded it to the robot by the time our robot has been manually reset. My plan is to move more parameters off the robot, like elevator height and shooting angles to further reduce the amount of times we have to redeploy the actual robot code.
Reply With Quote
  #18   Spotlight this post!  
Unread 06-27-2018, 07:16 PM
Tahsin Ahmed Tahsin Ahmed is offline
Registered User
FRC #0694
 
Join Date: Jan 2018
Location: New York
Posts: 15
Tahsin Ahmed is an unknown quantity at this point
Re: Pathfinder returning infinity?

I've tried to use the notifier in our code. Here is our implementation:
Code:
public DrivetrainMotionProfileJaciEncoderCommand(String nameOfPath, double dt, double maxVelocity) {
    	requires(Robot.drivetrain);
    	leftCSV = new File("/home/lvuser/Paths/" + nameOfPath + "_left_Jaci.csv");
    	rightCSV = new File("/home/lvuser/Paths/" + nameOfPath + "_right_Jaci.csv");
    	leftTraj = Pathfinder.readFromCSV(leftCSV);
        rightTraj = Pathfinder.readFromCSV(rightCSV);
        System.out.println("CSV has been locked and loaded");
    	this.maxVelocity = maxVelocity; 
    	this.dt = dt; 
    	profileProcessor = new Notifier(new RunProfile());
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

 protected void initialize() {
    	leftFollower = new EncoderFollower(leftTraj);
    	rightFollower = new EncoderFollower(rightTraj);
    	leftFollower.reset();
    	rightFollower.reset();
    	//Wheel diameter in feet
    	leftFollower.configureEncoder(Robot.drivetrain.leftBottomMotor.getSensorCollection().getQuadraturePosition(), RobotMap.DRIVETRAIN_ENCODER_TICKS_PER_REVOLUTION, RobotMap.DRIVETRAIN_WHEEL_DIAMETER / 12);
    	rightFollower.configureEncoder(Robot.drivetrain.rightBottomMotor.getSensorCollection().getQuadraturePosition(), RobotMap.DRIVETRAIN_ENCODER_TICKS_PER_REVOLUTION, RobotMap.DRIVETRAIN_WHEEL_DIAMETER / 12);
    	leftFollower.configurePIDVA(SmartDashboard.getNumber("kp", 0.0), SmartDashboard.getNumber("ki", 0), SmartDashboard.getNumber("kd", 0.0), 1 / maxVelocity, SmartDashboard.getNumber("ka", 0));
    	rightFollower.configurePIDVA(SmartDashboard.getNumber("kp", 0.0), SmartDashboard.getNumber("ki", 0), SmartDashboard.getNumber("kd", 0.0), 1 / maxVelocity, SmartDashboard.getNumber("ka", 0));
    	profileProcessor = new Notifier(new RunProfile());
    	profileProcessor.startPeriodic(dt);
    }

protected boolean isFinished() {
    	if(leftFollower.isFinished() && rightFollower.isFinished()){
    		System.out.println("Path has finished");
    		return true; 
    	}else {
    		return false; 
    	}
    }

protected void end() {
    	profileProcessor.stop();
    	Robot.drivetrain.stop();
    }

class RunProfile implements java.lang.Runnable {
    	int segmentNumber = 0; 
		@Override
		public void run() {
			double leftOutput = leftFollower.calculate(Robot.drivetrain.leftBottomMotor.getSensorCollection().getQuadraturePosition());
	    	double rightOutput = rightFollower.calculate(Robot.drivetrain.rightBottomMotor.getSensorCollection().getQuadraturePosition());
	    	double gyroHeading = Robot.drivetrain.getGyroAngle();
	    	double desiredHeading = Pathfinder.r2d(leftFollower.getHeading());
	    	//Pathfinder is counter-clockwise while gyro is clockwise so gyro heading is added
	    	double angleDifference = Pathfinder.boundHalfDegrees(desiredHeading + gyroHeading);
	    	//kg is the turn gain and is the p for the angle loop
	    	double turn = SmartDashboard.getNumber("kg", 0.08) * (-1.0 / 80.0) * angleDifference;
	    	Robot.drivetrain.tankDrive(leftOutput + turn, rightOutput - turn);
	    	System.out.println("Left Power: " + (leftOutput + turn) + " Right Power: " + (rightOutput - turn));
	    	segmentNumber++; 
		}
    }
We made dt 0.05 by the way.
However, when we tried to use this it ran for a while and then the path finished. We then had it print out the segment number and the segment and found out that the notifier ran too quickly. It got to the last point in like 1 second. I know I'm not using the wrong units, so what could be wrong with our notifier?
I also should mention that we also have another notifier in Robot running at the same rate, which logs data. That one works fine, as far as logging is concerned. We commented that out to ensure that it wasn't the problem, but it was the same results.
Reply With Quote
  #19   Spotlight this post!  
Unread 06-28-2018, 12:40 AM
jdao jdao is offline
Registered User
AKA: Jonathan Dao
FRC #4201 (Vitruvian Bots)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: United States
Posts: 23
jdao will become famous soon enough
Re: Pathfinder returning infinity?

Can you define how the notifier "ran too quickly"? Are you going through all your segments in the given path? Are you stopping in the middle of your path? (unlikely, given that you return true when both sides finish). Does your robot execute the path at the correct scale? For example, if you tell a robot to move in an S-curve 3 ft. forward and 3 ft. left from its initial position, is it actually going roughly 3 ft. or does it look like a scaled down version (like 2 ft. forward and 2 ft. left). If so your encoder counts per revolution may be incorrect. (Our team used a 360 counts per rev encoder for our wheels, but it's read through the Talon SRX using the quad encoder settings, which multiplies the value 4x so a full revolution ends up being 1440 instead of 360).

I don't see anything obviously wrong in your code. I would double check if the dt you're passing is actually 0.05 by printing it out. Secondly, I would double check the dt value in your .csv paths to make sure that they are 0.05.
Reply With Quote
  #20   Spotlight this post!  
Unread 06-28-2018, 09:26 AM
icemannie's Avatar
icemannie icemannie is offline
Registered User
AKA: John Boyle
FRC #2194 (Fondy Fire)
Team Role: Mentor
 
Join Date: Jul 2016
Rookie Year: 2011
Location: Fond du Lac, WI
Posts: 26
icemannie is an unknown quantity at this point
Re: Pathfinder returning infinity?

How many segments are in your profile? This should be the value in leftTraj.length.

Does segmentNumber agree with leftTraj.length after running?

You can use Timer.getFPGATimestamp() to determine your Notifier step time to find out what it is exactly.

What would be your expected profile time?

Your step time should be the same as leftFollower.getSegment().dt

You could also set your Notifier time step by reading that value.
Reply With Quote
  #21   Spotlight this post!  
Unread 06-28-2018, 09:45 AM
icemannie's Avatar
icemannie icemannie is offline
Registered User
AKA: John Boyle
FRC #2194 (Fondy Fire)
Team Role: Mentor
 
Join Date: Jul 2016
Rookie Year: 2011
Location: Fond du Lac, WI
Posts: 26
icemannie is an unknown quantity at this point
Re: Pathfinder returning infinity?

is

public DrivetrainMotionProfileJaciEncoderCommand(String nameOfPath, double dt, double maxVelocity) {

actually in your code

public class DrivetrainMotionProfileJaciEncoderCommand extends Command(String nameOfPath, double dt, double maxVelocity) {
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:54 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi