Robot Code Compiles but doesn't Run.

Hello, folks! Our team has recently made the switch from Java to C++. (Command Based) Over the Summer offseason, we worked on “porting” our old Java code to C++. We were able to eliminate the last of the compiler errors just last week. Our code compiles and uploads to the roboRio, however, the Robot doesn’t do anything. The Driver’s Station opens, and the code seems to be on the robot, but the robot never moves, whether it is Autonomous or Teleop.

At this point, our team is at a dead end, and we aren’t sure how to go about solving this problem. Is there an easy fix to this issue, or does it require a large amount of change and modifications? If anyone would be willing to take a look at our code on GitHub, it would be greatly appreciated! (https://github.com/Team5712/FRC_2016_Cpp)

Thanks so much in advance!

We are also getting the following error:

Program "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\cl" not found in PATH

Other posts claim this not to be a concern. However, we haven’t had any luck getting our robot to run.

Any possibility that this is a hardware problem, or otherwise unrelated to the code? Do you have another robot you could test this on?

It’s not a concern. There’s actually a way to fix it but I forget the solution atm and it doesn’t matter.

Your problem is in RobotMap. More specifically, you are actually getting either zeros or garbage (I don’t know the internals of GCC, so I don’t know which :)) when trying to access your RobotMap values. Print one and you’ll see. This is because they aren’t initialized.
Now why aren’t RobotMap values initialized? Because you never call the constructor where you have the initializations. So you could either call the constructor before you use any RobotMap values, or (the better solution) reorganize RobotMap.

Here’s how it might look instead


// RobotMap.h (get rid of RobotMap.cpp)
#pragma once

class RobotMap
{
public:
	static const int DRIVESTICK_JOYSTICK = 0;
	static const int SHOOTSTICK_JOYSTICK = 1;
	
	static const int LEFT_FRONT_MOTOR = 0;
	static const int LEFT_REAR_MOTOR = 1;
	static const int RIGHT_FRONT_MOTOR = 2;
	static const int RIGHT_REAR_MOTOR = 3;
	// and so on
};


This makes sure the variables are correctly initialized at program start, so you can use the actual values you want without further hassle.

^ Exactly. I’m surprised your code even compiles. You shouldn’t be able to assign values to const static variables in a constructor.

It’s also a little weird that your project files and directories are organized a lot like the ones RobotBuilder generates, but the code looks like it was written by hand. Any particular reason for that?