Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Code changes not deploying to robot? (http://www.chiefdelphi.com/forums/showthread.php?t=133652)

Dinnesy 29-01-2015 11:49

Code changes not deploying to robot?
 
My team has deployed the following code to our robot:
package org.usfirst.frc.team4968.robot;

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;

public class Robot extends SampleRobot
{
RobotDrive myRobot; // class that handles basic drive operations
Joystick leftStick; // set to ID 1 in DriverStation
Joystick rightStick; // set to ID 2 in DriverStation
public Robot()
{
myRobot = new RobotDrive(0, 1);
myRobot.setExpiration(0.1);
leftStick = new Joystick(0);
rightStick = new Joystick(1);
}
public void operatorControl()
{
myRobot.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled())
{
myRobot.arcadeDrive(leftStick);
//myRobot.tankDrive(leftStick, rightStick);
Timer.delay(0.005); // wait for a motor update time
}
}
}

Initially, the code was working. However we then tried redeploying the code with a few changes, and the robot stopped working. So, we reverted the code back to EXACTLY what it was when it was working, and redeployed it, but the robot still does not work. I believe this to because by our code is not successfully deploying to the robot, because no matter what we do, nothing seems to change and the robot does not respond. Could someone outline the code deploying process for us to ensure we are not missing anything? Does the build.xml file need to be updated?

BigJ 29-01-2015 11:53

Re: Code changes not deploying to robot?
 
Before doing anything else, try using some System.out.println statements to make sure whether the code is or is not getting updated on the bot.

Dinnesy 29-01-2015 12:23

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by BigJ (Post 1435642)
Before doing anything else, try using some System.out.println statements to make sure whether the code is or is not getting updated on the bot.

We have a very new and inexperienced coder this year and he is not very familiar with system.out.println statements, could you explain how we would do so? Thanks a Lot!

BigJ 29-01-2015 12:43

Re: Code changes not deploying to robot?
 
System.out.println("Hello world"); will print a line of text containing "Hello world" in the console. You can substitute any string for "Hello world".

Then you can look at the console output to see if your text is printing.

Dinnesy 29-01-2015 12:59

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by BigJ (Post 1435677)
System.out.println("Hello world"); will print a line of text containing "Hello world" in the console. You can substitute any string for "Hello world".

Then you can look at the console output to see if your text is printing.

I get the hello world printout infinitely in the console. So, that would imply that there is an issue with my code, however i am not getting any errors, and all of the ports are correct.

BigJ 29-01-2015 13:14

Re: Code changes not deploying to robot?
 
All that means is that you put that statement in a loop (this is okay). More importantly, it means that your code is being deployed and updated properly.

Jon Stratis 29-01-2015 13:54

Re: Code changes not deploying to robot?
 
The posted code is just for driving the robot... Have you verified through the driver station that the joysticks are still connected?. Unplugging them and then plugging them back in while the driver station is up can cause them to no longer be recognized or read.

Dinnesy 30-01-2015 09:40

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by Jon Stratis (Post 1435705)
The posted code is just for driving the robot... Have you verified through the driver station that the joysticks are still connected?. Unplugging them and then plugging them back in while the driver station is up can cause them to no longer be recognized or read.

Yes, they joysticks are connected and the driver station is recognizing all feedback from them.

notmattlythgoe 30-01-2015 09:48

Re: Code changes not deploying to robot?
 
What do the lights on the motor controllers do when you enable the robot?

Also, when posting code, please use code tags to make it easier to read. To use a code tag place a [/code] at the end and a [code] at the beginning. Thanks.

Dinnesy 30-01-2015 10:03

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by notmattlythgoe (Post 1436047)
What do the lights on the motor controllers do when you enable the robot?

Also, when posting code, please use code tags to make it easier to read. To use a code tag place a [/code] at the end and a [code] at the beginning. Thanks.

the light on the motor controllers(talons) do not change when the robot is enabled, they are always flashing orange. I will use the code tag from now on, sorry.

notmattlythgoe 30-01-2015 10:05

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by Dinnesy (Post 1436051)
the light on the motor controllers(talons) do not change when the robot is enabled, they are always flashing orange. I will use the code tag from now on, sorry.

No need to apologize, most people don't know about them. It just makes it easier to read.

The flashing talons means that they are note being communicated with. Can you verify that the talons are plugged into the correct ports and that they are plugged in correctly?

Dinnesy 30-01-2015 11:46

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by notmattlythgoe (Post 1436053)
No need to apologize, most people don't know about them. It just makes it easier to read.

The flashing talons means that they are note being communicated with. Can you verify that the talons are plugged into the correct ports and that they are plugged in correctly?

I took a look at the pwm's and it turns out that someone had put them back in incorrectly when we moved the drive base over. So now, the code is working and we have made some modifications to it. However, our left and right turning seems to be inverted. could anyone tell me how to modify it so that it turns correctly? I have tried changing the pwm ports but it has not effect.

Updated Code:
Code:

package org.usfirst.frc.team4968.robot;


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;

/**
 * This is a demo program showing the use of the RobotDrive class.
 * The SampleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 *
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SampleRobot
 * 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.
 *
 * WARNING: While it may look like a good choice to use for your code if you're inexperienced,
 * don't. Unless you know what you are doing, complex code will be much more difficult under
 * this system. Use IterativeRobot or Command-Based instead if you're new.
 */
public class Robot extends SampleRobot {
    RobotDrive myRobot;
    Joystick stick;

    public Robot() {
        myRobot = new RobotDrive(1, 0);
        myRobot.setExpiration(0.1);
        stick = new Joystick(1);
    }

    /**
    * Drive left & right motors for 2 seconds then stop
    */
    public void autonomous() {
        myRobot.setSafetyEnabled(false);
        myRobot.drive(-0.5, 0.0);        // drive forwards half speed
        Timer.delay(2.0);                //    for 2 seconds
        myRobot.drive(0.0, 0.0);        // stop robot
    }

    /**
    * Runs the motors with arcade steering.
    */
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
            Timer.delay(0.005);                // wait for a motor update time
        }
    }

    /**
    * Runs during test mode
    */
    public void test() {
    }
}

Thanks again!

notmattlythgoe 30-01-2015 11:51

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by Dinnesy (Post 1436082)
I took a look at the pwm's and it turns out that someone had put them back in incorrectly when we moved the drive base over. So now, the code is working and we have made some modifications to it. However, our left and right turning seems to be inverted. could anyone tell me how to modify it so that it turns correctly? I have tried changing the pwm ports but it has not effect.

Updated Code:
Code:

package org.usfirst.frc.team4968.robot;


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;

/**
 * This is a demo program showing the use of the RobotDrive class.
 * The SampleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 *
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SampleRobot
 * 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.
 *
 * WARNING: While it may look like a good choice to use for your code if you're inexperienced,
 * don't. Unless you know what you are doing, complex code will be much more difficult under
 * this system. Use IterativeRobot or Command-Based instead if you're new.
 */
public class Robot extends SampleRobot {
    RobotDrive myRobot;
    Joystick stick;

    public Robot() {
        myRobot = new RobotDrive(1, 0);
        myRobot.setExpiration(0.1);
        stick = new Joystick(1);
    }

    /**
    * Drive left & right motors for 2 seconds then stop
    */
    public void autonomous() {
        myRobot.setSafetyEnabled(false);
        myRobot.drive(-0.5, 0.0);        // drive forwards half speed
        Timer.delay(2.0);                //    for 2 seconds
        myRobot.drive(0.0, 0.0);        // stop robot
    }

    /**
    * Runs the motors with arcade steering.
    */
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
            Timer.delay(0.005);                // wait for a motor update time
        }
    }

    /**
    * Runs during test mode
    */
    public void test() {
    }
}

Thanks again!

I'm guessing you have your motor ports backwards, try changing it to this:

Code:

myRobot = new RobotDrive(0, 10);
RobotDrive takes in the left side, then the right side.

Dinnesy 30-01-2015 12:06

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by notmattlythgoe (Post 1436083)
I'm guessing you have your motor ports backwards, try changing it to this:

Code:

myRobot = new RobotDrive(0, 10);
RobotDrive takes in the left side, then the right side.

I applied your change and redeployed the code, however nothing has changed. I'm still getting the same issue. any other idea's?

notmattlythgoe 30-01-2015 12:07

Re: Code changes not deploying to robot?
 
Quote:

Originally Posted by Dinnesy (Post 1436091)
I applied your change and redeployed the code, however nothing has changed. I'm still getting the same issue. any other idea's?

Oops, that should be (0, 1) not (0, 10).


All times are GMT -5. The time now is 13:17.

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