Go to Post ...our football team was a state champion, but i don't see -them- going to atlanta and winning there! :D - Sam Lipscomb [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-10-2016, 08:29 PM
samrmur samrmur is offline
Registered User
FRC #3756
 
Join Date: Feb 2016
Location: London, Ontario
Posts: 3
samrmur is an unknown quantity at this point
New to FRC Programming

Hello,

I'm very new to FRC programming and need help programming my team's robot because we don't have much time remaining. I've tried doing what I can but it doesn't work. My team has 6 Victors for the drive train and since the RobotDrive.class only support up to 4, I am unsure how to connect the other two. Also, when opening up SmartDashboard, no options for the autonomous commands display and I am unsure how to display it. My code has been uploaded to GiftHub: https://github.com/samrmur/FRCRobot/...rierRobot.java

Thanks in Advance,
Samer
Reply With Quote
  #2   Spotlight this post!  
Unread 02-10-2016, 09:26 PM
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,117
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: New to FRC Programming

How are the 6 motors driving the wheels?

If any are in 2 motor gear boxes, then you can use a Pwm splitter to drive the two motor controllers. It will then look like one motor to the software.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-10-2016, 11:18 PM
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: New to FRC Programming

The PWM splitter is a great way to solve this problem.

If you don't have a PWM splitter and it will take you awhile to get one, you can use a software approach by adding a new SpeedControllerArray class to your project (shown below). This class controls an array of motors as if they were one. It is a simple implementation that expects that all of the motors turn the same direction (for example, if you want to set a power of .5 on one, you will be setting them all to .5).

To use the SpeedControllerArray class in your Robot.java, you will need to create a SpeedControllerArray.java file with the code shown below in the same package as your Robot.java file and then change your RobotDrive construction from:

Code:
    RobotDrive driveRobot = new RobotDrive(frontLeft, backLeft, frontRight, backRight);
To:

Code:
    SpeedController[] leftSideMotors = { frontLeft, middleLeft, backLeft };
    SpeedController[] rightSideMotors = { frontRight, middleRight, backRight };
    
    SpeedController leftSide = new SpeedControllerArray(leftSideMotors);
    SpeedController rightSide = new SpeedControllerArray(rightSideMotors);
    
    RobotDrive driveRobot = new RobotDrive(leftSide, rightSide);
Here is the source for the SpeedControllerArray class. NOTE: Please review (I think it is OK, but it has not been verified it on a live robot).

Code:
package org.usfirst.frc.team3756.robot;

import edu.wpi.first.wpilibj.SpeedController;

/**
 * A SpeedController implementation that wraps an array of one or more
 * SpeedController objects so they look like a single SpeedController (a
 * software version of a PWM splitter cable).
 */
public class SpeedControllerArray implements SpeedController {
	
	// Array of motors to control like one
	private SpeedController[] motors;

	public SpeedControllerArray(SpeedController[] motors) {
		if (motors.length < 1) {
			throw new IllegalArgumentException("You must pass an array of at least one SpeedController");
		}
		this.motors = motors;
	}

	@Override
	public void pidWrite(double output) {
		set(output);
	}

	@Override
	public double get() {
		// Since all motors have same value, return value from first one
		return motors[0].get();
	}

	@Override
	public void set(double speed, byte syncGroup) {
		for (SpeedController motor : motors) {
			motor.set(speed, syncGroup);
		}
	}

	@Override
	public void set(double speed) {
		for (SpeedController motor : motors) {
			motor.set(speed);
		}
	}

	@Override
	public void setInverted(boolean isInverted) {
		for (SpeedController motor : motors) {
			motor.setInverted(isInverted);
		}
	}

	@Override
	public boolean getInverted() {
		// Since all motors have same value, return value from first one
		return motors[0].getInverted();
	}

	@Override
	public void disable() {
		for (SpeedController motor : motors) {
			motor.disable();
		}
	}

}
Good luck, and I hope you found the PWM splitter cable as that is a simpler hardware solution to the problem.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-11-2016, 03:41 PM
samrmur samrmur is offline
Registered User
FRC #3756
 
Join Date: Feb 2016
Location: London, Ontario
Posts: 3
samrmur is an unknown quantity at this point
Re: New to FRC Programming

It worked, but today we figured out that the problem was not with the code, the wiring was messed up and the gear boxes are not working properly, thanks for the help
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 07:28 AM.

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