Looking for some help with some code issues

#1

Our team swapped over to vex this year but we’re working on some side projects due to the swap over no one learned vex coding I’m down to one error now: C:\Users\Administrator\Desktop\t-SHIRT launcher\t-shirt_Launcher\t-shirtattempt\src\main\java\frc\robot\Robot.java:10: error: class, interface, or enum expected
package frc.robot;

and the code is here:

 /*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. 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 org.usfirst.frc.team4979.robot;

package frc.robot;


import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PWMVictorSPX;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.MecanumDrive;
import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Compressor;

import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.IterativeRobot;

public class Robot extends IterativeRobot {

public void robotInit() {
    CameraServer.getInstance().startAutomaticCapture();
}
}



/**
 * This is a demo program showing how to use Mecanum control with the RobotDrive
 * class.
 */
public class Robot extends TimedRobot {
  private static final int kFrontLeftChannel = 2;
  private static final int kRearLeftChannel = 3;
  private static final int kFrontRightChannel = 1;
  private static final int kRearRightChannel = 0;

  private static final int kJoystickChannel = 0;

  private MecanumDrive m_robotDrive;
  private Joystick m_stick;

  @Override
  public void robotInit() {
m_frontLeft = new Spark(0);	
m_rearLeft = new Spark(1);
	m_frontRight = new Spark(14);	
	m_rearRight = new Spark(15);

// Invert the left side motors.
// You may need to change or remove this to match your robot.
frontLeft.setInverted(true);
rearLeft.setInverted(true);

m_robotDrive = new MecanumDrive(frontLeft, rearLeft, frontRight, rearRight);

m_stick = new Joystick(kJoystickChannel);
  }

  //Override
  public void teleopPeriodic() {
// Use the joystick X axis for lateral movement, Y axis for forward
// movement, and Z axis for rotation.
m_robotDrive.driveCartesian(m_stick.getX(), m_stick.getY(),
    m_stick.getZ(), 0.0);




  }


  //This is where I think Pnematics will begin

  Compressor c = new Compressor(0);


  //This should create the solenoid in the code

  public void teleopPeriodic() {

DoubleSolenoid launchersolenoid = new DoubleSolenoid(1, 2);

launchersolenoid.set(DoubleSolenoid.Value.kOff);
launchersolenoid.set(DoubleSolenoid.Value.kForward);
launchersolenoid.set(DoubleSolenoid.Value.kReverse);

  }

  //This section is what should allow us to toggle the cylinders in and out with button 1

  public class MyRobot extends IterativeRobot{
public void robotInit(){
    
}

boolean toggleOn = false;
boolean togglePressed = false;

public void teleopPeriodic(){
    updateToggle();

    if(toggleOn){
        launchersolenoid.set(DoubleSolenoid.Value.kForward);
    }else{
        launchersolenoid.set(DoubleSolenoid.Value.kReverse);
    }
}

public void updateToggle()
{
    if(joystick.getRawButton(1)){
        if(!togglePressed){
            toggleOn = !toggleOn;
            togglePressed = true;
        }
    }else{
        togglePressed = false;
    }
}

//This might let us turn compressors on and off with button 2




}
}

Can anyone help me out?

0 Likes

#2

You have two “public class Robot” classes; Java only allows one per file.

0 Likes

#3

ok, I see what you mean by that which should I get rid of and what other changes might that lead to?

I’m honestly figuring this out as I go along since I little to no code experience the stuff you see there is my first ever attempt

Follow up question, since I don’t know much code would I be better off trying labview?

0 Likes

#4

Iterative Robot was deprecated this year and replaced by Timed Robot so I suggest using that.

0 Likes

#5

In my opinion, Labview is even more confusing than Java.

1 Like

#6

ok I’ll try that I was using a mix of old and new code I found so that may be the main issue

0 Likes

#7

Ok so for now I just cut out the camera code that was under iterative and now I’m up to 28 errors

0 Likes

#8

Ok, so I’m now at this point with 10 errors in the drive section of the code. I’m getting a can’t find symbol error in this section

 @Override
  public void robotInit() {
    m_frontLeft = new Spark(0);	
    m_rearLeft = new Spark(1);
	m_frontRight = new Spark(14);	
	m_rearRight = new Spark(15);

    // Invert the left side motors.
    // You may need to change or remove this to match your robot.
    frontLeft.setInverted(true);
    rearLeft.setInverted(true);

    m_robotDrive = new MecanumDrive(frontLeft, rearLeft, frontRight, rearRight);

    m_stick = new Joystick(kJoystickChannel);
  }

error is in relation to the m_frontLeft and etc. and m_robotDrive

0 Likes

#9

Well I manged to figure it out and get to build successfully had to add var to the code now I just need to add some buttons which may lead to some more problems

0 Likes