Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Just began using Java (http://www.chiefdelphi.com/forums/showthread.php?t=123449)

BlackUnicorns 20-12-2013 08:53

Just began using Java
 
hey guys, we are team 5135 from israel, and we just started programming with java.

so we were wondering if you can help us get started (:

Thx!,
Frc 5135 - Black Unicorns

Jon Stratis 20-12-2013 09:14

Re: Just began using Java
 
Check out the powerpoint our team gave at the MN Splash event a few weeks ago: http://www.therobettes.com/sites/def...mmandBase.pptx

If you have any questions, I'm sure our programmers would be willing to help! Just drop us an e-mail at 2177@therobettes.com

nickmcski 20-12-2013 09:14

Re: Just began using Java
 
I would recommend going to this website, its the website for the API that you will be using to program. It goes through all the steps to setup your development environment. http://wpilib.screenstepslive.com/s/...elopment-tools

I hope that will be enough to get started, if you have any more questions or encounter any problems I would be delighted to help you!

BlackUnicorns 20-12-2013 12:49

Re: Just began using Java
 
Thank you!
We tried to make an arcade drive program (before, we used LabView to drive our robot), and we have a little problem.. this is our code:
Code:

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                            */
/* Open Source Software - may be modified and shared by FRC teams. The code  */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                              */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
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 SimpleRobot
 * 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 RobotTemplate extends SimpleRobot {
    /**
    * This function is called once each time the robot enters autonomous mode.
    */
    Joystick driveStick = new Joystick(1);
    RobotDrive  myDrive = new RobotDrive(1, 2);
    public void autonomous() {
       
    }

    /**
    * This function is called once each time the robot enters operator control.
    */
    public void operatorControl() {
        while (isOperatorControl() && isEnabled()){
            myDrive.arcadeDrive(driveStick);
            Timer.delay(0.01);
        }
    }
}

Forword and backwords works fine, but the problem was with left and right..
when you turn right it turns left, and left turns right..
Can you tell us what we did wrong? :(

We really appreciate your help, thank you very much (:

Jon Stratis 20-12-2013 12:58

Re: Just began using Java
 
Change this line:

RobotDrive myDrive = new RobotDrive(1, 2);

to:

RobotDrive myDrive = new RobotDrive(2, 1);


Think about what's happening. When you push forwards on the joystick, the RobotDrive tells both motors (1 and 2) to drive forward, which works fine. Likewise, pulling the joystick backwards makes both motors go backwards.

But if you want to turn left (spin in place) then one motor has to go forwards and one has to go backwards. In this case, it picked the wrong ones, and as a result spins in the wrong direction. By switching the order you pass in the motors, you'll switch it's choice and it'll turn in the right direction.

BlackUnicorns 20-12-2013 13:17

Re: Just began using Java
 
Quote:

Originally Posted by Jon Stratis (Post 1314994)
Change this line:

RobotDrive myDrive = new RobotDrive(1, 2);

to:

RobotDrive myDrive = new RobotDrive(2, 1);


Think about what's happening. When you push forwards on the joystick, the RobotDrive tells both motors (1 and 2) to drive forward, which works fine. Likewise, pulling the joystick backwards makes both motors go backwards.

But if you want to turn left (spin in place) then one motor has to go forwards and one has to go backwards. In this case, it picked the wrong ones, and as a result spins in the wrong direction. By switching the order you pass in the motors, you'll switch it's choice and it'll turn in the right direction.

What you say makes a lot of sense, but i remember that we tried doing it today and it didnt work..
I dont have the robot now to try it but i will try it tomorrow and see if it works.

by the way, i remember when we used labview, it had a robot simulator, does java has something like that too?

Joe Ross 20-12-2013 13:43

Re: Just began using Java
 
Quote:

Originally Posted by BlackUnicorns (Post 1315002)
by the way, i remember when we used labview, it had a robot simulator, does java has something like that too?

There isn't an official java simulator like there is for LabVIEW.

I've seen a few different attempts where people have tried to put one together, for example http://www.chiefdelphi.com/forums/sh...d.php?t=112024, but I have not tried any of them.


All times are GMT -5. The time now is 10:37.

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