|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Vision
Depends what you're trying to accomplish. I'll note that the post-processing you're doing in the lambda assumes the first contour it sees is one of the boiler stripes, which may not always be the case.
centerX() should synchronize on the lock, otherwise the main robot thread may not get the most recent values (or any values at all. Threads are weird that way). Code:
public double centerX() {
synchronized (imgLock) {
return centerX;
}
}
|
|
#2
|
|||
|
|||
|
Re: Vision
Thank you!
![]() |
|
#3
|
|||
|
|||
|
Re: Vision
Thanks. Does this command work with it?
package org.usfirst.frc.team1025.robot.commands; import org.usfirst.frc.team1025.robot.Robot; import org.usfirst.frc.team1025.robot.subsystems.Vision; import edu.wpi.first.wpilibj.command.Command; /** * */ public class VisionAuton extends Command { double centerX; public VisionAuton() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); requires(Robot.visionSubsystem); requires(Robot.ChassisSubsystem); } // Called just before this Command runs the first time protected void initialize() { } // Called repeatedly when this Command is scheduled to run protected void execute() { synchronized (Robot.visionSubsystem.imgLock) { Robot.visionSubsystem.centerX = this.centerX; } double Turn = centerX - (Vision.IMG_WIDTH / 2 ); // ask // Robot.chassisSubsystem.SimpleDrive(leftSpeed, rightSpeed); Robot.ChassisSubsystem.getRobotDrive().arcadeDrive (-0.6, Turn * 0.005); } // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { return false; } // Called once after isFinished returns true protected void end() { } // Called when another command which requires one or more of the same // subsystems is scheduled to run protected void interrupted() { } } |
|
#4
|
||||
|
||||
|
Re: Vision
execute() won't work. You're overwriting the vision centerX instead of copying it. You should make the centerX variable in VisionSubsystem be private to avoid problems like this.
Code:
synchronized (Robot.visionSubsystem.imgLock) {
Robot.visionSubsystem.centerX = this.centerX;
}
Code:
synchronized (Robot.visionSubsystem.imgLock) {
this.centerX = Robot.visionSubsystem.centerX();
}
|
|
#5
|
|||
|
|||
|
Re: Vision
ok thanks
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|