Comms, Code, and Joystick are shown, but robot gives no response

Heys, im having a lot of issue with our robot unable to move. We have comms, code, and joystick active, and it says that we’re good to go, but nothing happens, no movement no nothing.

heres the code on my github:

my brain is fried and i dont know whats the issue, if anyone could help me out, i will be forever in your debt

Check in the Driver Station USB tab to be sure the joysticks are in the positions your code expects, e.g., 0,1,2,3, or 4

Don’t call teleopPeriodic from teleopPeriodic. That is causing your robot to go into an infinite loop forever, and not run anything else.

2 Likes

You seem to be calling teleopPeriodic in teleopPeriodic. Other than that, you have a drive method in your Robot class, but are not calling it anywhere. Putting it there is also bad practice given the new command-based framework. Read up on it here.

still no response, i changed the teleop command, still nothing

Where are you calling Robot.drive() from?
Also, that should really be a command. With the new command framework, you shouldn’t really be putting things in Robot.java.

then where should i be putting these commands? all the examples im looking at are being put in the Robot.java

You’re probably looking at old command examples. See https://docs.wpilib.org/en/latest/docs/software/commandbased/structuring-command-based-project.html
Commands should go in the commands folder and be called from RobotContainer, or as default commands from RobotContainer with subsystem.setDefaultCommand(Command command)

so instead of putting commands in the robot.java, i should be putting them in the robot container? so like the robot container just like the robot.java from old commands? is that what im getting? Like movements, cameraservers, color sensor codes should all be in the robot container?

I think the main problem is that your driver object that you try to arcade drive with doesn’t exist. Unless it does and i can’t see it, I am unable to see from where you are calling that function. Also in tele-op periodic just put drive(joystick); and pass which ever joystick you re using

but should there be anything in the robot.java? or is the driving code ok to put in?

Commands are not methods. each command should be a separate file (inlines notwithstanding). So you would put your driving code in a command and set that as the default command in your subsystem. Then it will run periodically while still being interruptible when you want to do something different with the drivebase.
Nothing should be in Robot.java except what auto-generated. Most of what used to go in robot.java has been moved to RobotContainer.

ive been making methods instead of commands? i guess that makes sense, if you cant tell already, im still very new to all of this, so sorry if im making you guys bang your heads on the computer wanting to hurt me lol

So if im making a command, which is linked to the drive train, i would make a command, in this case i made an input command in the subsystem, would i then just put in the input values in the robotcontainer and stuff like that and call it from those subsystems? Same thing with like color sensor codes, and autonomous codes? and stay absolutely away from the robot.java correct? that way i dont make a mess in the robot.java? Then everything should be running properly? is that what im getting?

You make a command that implements CommandBase, put it in the commands folder, and pass in as a parameter an object of type Drivetrain, as well as your InputJoystick object. Then have a variable in your command that will store your drivetrain object. In the constructor of the command set your variable equal to the subsystem you passed in. then you get to the command methods. initialize() is for setting stuff up. probably not necessary in this case. execute() will run every tick while the command is running. This is where you call manualDrive() with your joystick parameters. Then you have isFinished() make this return false for your default teleop drive command.
for end() do nothing, or stop the motors. your choice.

I pointed this out yesterday… Code deployment won't go through Roborio

Robot container is very similar to the old OI file. That is the place where you configure your joystick to various commands. This is also the place where you declare default command and autonomous code.

so when you say

you mean bring imports of those subsystems into the manual drive? if so how would i type that in the code?

You would, do the following
Import drivetrain
Import input joystick
Create private variable of type Drivetrain and InputJoystick, but don’t initialize them

in your command constructor have parameters: (Drivetrain drive, InputJoystick stick)
Then below that set your private variables to the parameters passed in and use the private variables as your objects for calling methods.

I don’t know what other people are saying as I’m new also but we just had an inline command that was the drive sub-systems default in “configurebuttonbindings” method in robot container. We passed a -getY and getX to our arcade drive and required our drive sub-system. Make sure to import the drive sub-system. Also I believe that you instantiate your sub-system objects in Robot container, too. Also not related to your question but I believe when a command object is instantiated it starts running, so don’t create commands in the same style of a sub-system.

This is not true btw. They only start running when scheduled. In fact you can create one and start it multiple times.

2 Likes