Go to Post Stand strong mentors. You never know who you have become a brother, sister, father, or mother to. - MysterE [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
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 01-02-2017, 17:06
riptide321 riptide321 is offline
Registered User
FRC #4404
 
Join Date: Jan 2017
Location: St. Louis
Posts: 4
riptide321 is an unknown quantity at this point
Novice Coder Help

The robot has the code on the roboRio and is connected to the driver station. The joystick is also connected but none of the motors are firing when the joystick is moved.

Here is the code:

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

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.Timer;


/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Robot extends IterativeRobot {
	Joystick mainStick;
	Timer timer = new Timer();
	RobotDrive drive;
	Solenoid gearDropper = new Solenoid(1);
	Spark rightMotor1;
	Spark rightMotor2;
	Spark leftMotor1;
	Spark leftMotor2;
	



	/**
	 * This function is run when the robot is first started up and should be
	 * used for any initialization code.
	 */
	@Override
	public void robotInit() {
		rightMotor1 = new Spark(0);
		rightMotor2 = new Spark(1);
		leftMotor1 = new Spark(2);
		leftMotor2 = new Spark(3);
		
		drive = new RobotDrive(rightMotor2, rightMotor1, leftMotor2, leftMotor1);
		mainStick = new Joystick(0);
		
		
		
	}

	/**
	 * This autonomous (along with the chooser code above) shows how to select
	 * between different autonomous modes using the dashboard. The sendable
	 * chooser code works with the Java SmartDashboard. If you prefer the
	 * LabVIEW Dashboard, remove all of the chooser code and uncomment the
	 * getString line to get the auto name from the text box below the Gyro
	 *
	 * You can add additional auto modes by adding additional comparisons to the
	 * switch structure below with additional strings. If using the
	 * SendableChooser make sure to add them to the chooser code above as well.
	 */
	@Override
	public void autonomousInit() {
		timer.reset();
		timer.start();
	}

	/**
	 * This function is called periodically during autonomous
	 */
	@Override
	public void autonomousPeriodic() {
		
	}

	/**
	 * This function is called periodically during operator control
	 */
	@Override
	public void teleopPeriodic() 
	{
		drive.arcadeDrive(mainStick);
		boolean buttonValue, isOpen;
		isOpen = false;
		buttonValue = mainStick.getTrigger();
		if(buttonValue)
		{
			if(!isOpen)
			{
				gearDropper.set(true);
			}
			else
			{
				gearDropper.set(false);
			}
			
			isOpen = !isOpen;
			
		}
		
	}

	/**
	 * This function is called periodically during test mode
	 */
	@Override
	public void testPeriodic() {
	}
}
What is the solution to this problem?
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2017, 17:50
caleby caleby is offline
Registered User
FRC #1432
 
Join Date: Oct 2015
Location: Portland, Oregon
Posts: 6
caleby is on a distinguished road
Re: Novice Coder Help

Do the lights on the motor controllers change colors when you move the joystick?
Have you confirmed that your PWMs are plugged in correctly?
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2017, 18:00
riptide321 riptide321 is offline
Registered User
FRC #4404
 
Join Date: Jan 2017
Location: St. Louis
Posts: 4
riptide321 is an unknown quantity at this point
Re: Novice Coder Help

Quote:
Originally Posted by caleby View Post
Do the lights on the motor controllers change colors when you move the joystick?
Have you confirmed that your PWMs are plugged in correctly?
The PWM's leds flash on and off
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2017, 18:08
caleby caleby is offline
Registered User
FRC #1432
 
Join Date: Oct 2015
Location: Portland, Oregon
Posts: 6
caleby is on a distinguished road
Re: Novice Coder Help

The PWM is the black, white, and red cord that goes between the roborio and the motor controller. Is it plugged in properly? The light on the motor controller should change to red or green depending on which way your joystick is.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2017, 18:15
T8PineappleSam T8PineappleSam is offline
Jonathan
AKA: Jonathan Zwiebel
FRC #0008 (Paly Robotics)
Team Role: Driver
 
Join Date: Jan 2016
Rookie Year: 2013
Location: California
Posts: 29
T8PineappleSam will become famous soon enoughT8PineappleSam will become famous soon enough
Re: Novice Coder Help

I would recommend printing out the joystick values or going to the USB Devices tab in the driver station to ensure that it is giving actual values. It is possible that your joystick or USB connection is the issue.
__________________
Jonathan Zwiebel
Driver, Project Manager, Programmer [Team 8, Paly Robotics]




2016 Central Valley Regional Finalist and Wildcard, Silicon Valley Regional Quarterfinalist, Curie Division, CalGames Quarterfinalist and Entrepreneurship Award, Capital City Classic Quarterfinalist
2015 Central Valley Regional Entrepreneurship Award, Silicon Valley Regional Entrepreneurship Award, Capital City Classic Semifinalist and Judges' Award
2014 Central Valley Regional, Silicon Valley Regional, Chezy Champs
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2017, 18:44
ben47955 ben47955 is offline
Registered User
FRC #3996 (RIKITIK)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Canada
Posts: 14
ben47955 is an unknown quantity at this point
Re: Novice Coder Help

Code:
isOpen = false;
		buttonValue = mainStick.getTrigger();
		if(buttonValue)
		{
			if(!isOpen)
			{
				gearDropper.set(true);
			}
			else
			{
				gearDropper.set(false);
			}
			
			isOpen = !isOpen;
			
		}
isOpen will be always false, you have to put the variable global.

Check if your joystick is really in port 0 in driverStation.
Reply With Quote
  #7   Spotlight this post!  
Unread 01-02-2017, 20:30
Adnewhouse's Avatar
Adnewhouse Adnewhouse is offline
Registered User
FRC #0639
Team Role: College Student
 
Join Date: Jun 2013
Rookie Year: 2012
Location: Ithaca, NY
Posts: 21
Adnewhouse is an unknown quantity at this point
Re: Novice Coder Help

If the LED's are blinking, you might have the limit switch settings configured wrong or the PWM connection is not hooked up correctly. You should check the cable orientation and read the manual to match the blink code to the operating state of your Spark. It will also tell you how to make sure the limit switch configuration is correct in the manual. Other than the issue with the isOpen variable, your code looks correct. (Keeping in mind I'm not familiar with Java wpilib stuff)
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 19:37.

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