Go to Post Dear Dave, I've been a good student this year. Can I have hint #2 for Christmas? ~Zach - Zach O [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2016, 15:05
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 38
Lesafian is an unknown quantity at this point
Programming or Electrical Issue?

Our team is using 2 CIM motors using Victor speed controllers. Here's the code that I've written.
Code:
package org.usfirst.frc.team6077.robot;

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.TalonSRX;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Robot extends SampleRobot {

    // RobotDrive Declaration
	RobotDrive drive;
	
	// Compressor Declaration
	Compressor compressor;
	
	// Solenoid Declaration
	DoubleSolenoid doublesolenoid;
	Solenoid solenoid;

	// Joystick Declaration
	Joystick xboxController;

	// Motor Controller Declaration
	TalonSRX armMotor;
	TalonSRX slideMotor;
	
	Victor drivemotor1;
	Victor drivemotor2;

	// Autonomous Names
	final String defaultAuto = "Default";
	final String customAuto = "Autonomous Choice 1";
	final String customAuto2 = "Autonomous Choice 2";
	final String customAuto3 = "Autonomous Choice 3";
	final String customAuto4 = "Autonomous Choice 4";
	final String customAuto5 = "Autonomous Choice 5";

	// Chooser
	SendableChooser chooser;

	public Robot() {
		
		//Change values later
		drivemotor1 = new Victor(0);
		drivemotor2 = new Victor(2);
		
		compressor = new Compressor(0);
		
		drive = new RobotDrive(drivemotor1, drivemotor2);
		drive.setExpiration(0.1);
		
		xboxController = new Joystick(0);
		
		armMotor = new TalonSRX(5);
		slideMotor = new TalonSRX(4);

		doublesolenoid = new DoubleSolenoid(0, 1);
		solenoid = new Solenoid(2);

		chooser = new SendableChooser();
		
		LiveWindow.addActuator("Drive", "Left Motor", drivemotor1);
		LiveWindow.addActuator("Drive", "Right Motor", drivemotor2);

	}

	public void robotInit() {
		compressor.start();
		compressor.setClosedLoopControl(true);
		chooser.addDefault("Default Auto", defaultAuto);
		chooser.addObject("Autonomous Choice 1", customAuto);
		chooser.addObject("Autonomous Choice 2", customAuto2);
		chooser.addObject("Autonomous Choice 3", customAuto3);
		chooser.addObject("Autonomous Choice 4", customAuto4);
		chooser.addObject("Autonomous Choice 5", customAuto5);
		SmartDashboard.putData("Autonomous Chooser", chooser);
	}

	public void autonomous() {
		drive.setSafetyEnabled(false);
		String autoSelected = (String) chooser.getSelected();
		System.out.println("Autonomous Mode selected: " + autoSelected);

		switch (autoSelected) {

		case customAuto5:
			break;
		case customAuto4:
			break;
		case customAuto3:
			break;
		case customAuto2:
			break;
		case customAuto:
			break;
		case defaultAuto:
		default:
			break;
		}
		Scheduler.getInstance().run();
	}

	public void operatorControl() {
		drive.setSafetyEnabled(false);
		while (isOperatorControl() && isEnabled()) {
			
			// Move robot using left and right joystick
			drive.tankDrive(xboxController.getRawAxis(0), xboxController.getRawAxis(5));

			// Lift and lower the arms using the right and left bumper.

			if (xboxController.getRawButton(5)) {
				armMotor.set(1);

			} else if (xboxController.getRawButton(4)) {
				armMotor.set(-1);
				
			} else {
				
				armMotor.set(0);
			}

			// Move sliding mechanism forwards and backwardss
			
			if (Math.abs(xboxController.getRawAxis(5)) > .1) {
     
				slideMotor.set(xboxController.getRawAxis(5));
				
			} else {
				
				slideMotor.set(0);
            }

			// Open and close the claw
			if (xboxController.getRawButton(2)) {
				doublesolenoid.set(DoubleSolenoid.Value.kForward);
				
			} else if (xboxController.getRawButton(1)) {
				doublesolenoid.set(DoubleSolenoid.Value.kReverse);
			}
		}
	}

	public void test() {
	}
There are 0 errors in eclipse, and it builds successfully. The Riolog shows nothing, and the driver station shows 0 errors.

We're using an XBoxController. I'm also positive that we're using PWM port 0, and 2 for our CIM drive motors.

The problem is, the drive motors do not move. The compressor turns on, and for what we have hooked up, pneumatics works.

**UPDATE**
After going through everything, I've realized that I had Victors programmed when we were using VictorSP's. The drive now works.

Last edited by Lesafian : 07-02-2016 at 15:30.
  #2   Spotlight this post!  
Unread 07-02-2016, 15:13
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Programming or Electrical Issue?

Are your victors outputting any voltage/getting signal?

Did you ensure those numbers (0 and 2) are the correct numbers for the Victors?
__________________
1771- Programmer, Captain, Drive Team (2009-2012)
4509- Mentor (2013-2015)
1771- Mentor (2015)
  #3   Spotlight this post!  
Unread 07-02-2016, 15:15
Christopher149 Christopher149 is offline
Registered User
FRC #0857 (Superior Roboworks) FTC 10723 (SnowBots)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2007
Location: Houghton, MI
Posts: 1,109
Christopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond repute
Re: Programming or Electrical Issue?

Are you sure you are deploying the correct project? (happened to us one day preseason)

By "pneumatics works", does that mean you can actuate some of the solenoids?
__________________
2015-present: FTC 10723 mentor
2012-present: 857 mentor
2008-2011: 857 student

2015: Industrial Design, Excellence in Engineering, District Finalist, Archimedes Division (#6 alliance captain)
2014: Judges Award, District Engineering Inspiration, District Finalist, Galileo Division

  #4   Spotlight this post!  
Unread 07-02-2016, 15:23
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,723
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Programming or Electrical Issue?

Follow the signal all the way from joystick to motion - you could have issues at any step. Here are a few things to try:
  • Watch the diagnositcs on the motor controller. Are they in neutral or drive forward or reverse? (I'm not familiar with the Victors' colors; we haven't used them since I got involved.) If the lights show the right answer, it's somewhere between the controller and the wheel. If they don't, it's somewhere on the user/rio side of the controller (or in the controller).
  • Monitor the input arguments to drive.tankDrive(). If these are bad, check the joysticks, both wiring and programming.
  • Try adding commands to individually spin the drive motors, similar to what you're doing with the actuators. This will help verify that the motors are connected to the ports you're expecting.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
  #5   Spotlight this post!  
Unread 08-02-2016, 15:02
tuskiomi tuskiomi is offline
Registered User
None #2531
 
Join Date: Feb 2016
Location: Earth
Posts: 8
tuskiomi is an unknown quantity at this point
Re: Programming or Electrical Issue?

You don't have a wait method in the periodic. The motors cannot update.
put the line "Timer.delay(0.0075);" at the end of your public void operatorControl() method.

source: https://wpilib.screenstepslive.com/s/4485/m/13809/l/241857-getting-your-robot-to-drive-with-the-robotdrive-class
Closed Thread


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 01:29.

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


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