VRC V5 using structs

typedef struct{ 
int mass; 
double CurrentXAxis;
double CurrentYAxis;
double CurrentTheta;

double TargetXAxis;
double TargetYAxis;
double TargetTheta;

double CurrentXEncoderValue;
double CurrentYEncoderValue;
double CurrentThetaValue;

double CurrentXVelocity;
double CurrentYVelocity;
double CurrentRVelocit;

double MaxXVelocity;
double MaxYVelocity;
double MaxRVelocitiy;
}Robot_Telemetry;

Robot_Telemetry ricky;

ricky.MaxRVelocity = 0;

Error: [clang] unknown type name ‘ricky’

I am new to structs and trying to improve my code. It will just be used to pass a group of data around between functions. Are structs even possible in the v5 brain? Any help on what this even means would be great. (This example is just in the main loop of an empty project)

There are two main issues with your code.

  1. You have misspelled MaxRVelocity inside of your struct.

  2. You cannot assign values to members in that scope that way. One way to fix it is to move ricky.MaxRVelocity = 0; inside a function such as main(). Alternatively, you can use static initialization like this:

Robot_Telemetry ricky = {
  .MaxRVelocity = 0
};

More info on this here

Code
// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

typedef struct{ 
  int mass; 
  double CurrentXAxis;
  double CurrentYAxis;
  double CurrentTheta;

  double TargetXAxis;
  double TargetYAxis;
  double TargetTheta;

  double CurrentXEncoderValue;
  double CurrentYEncoderValue;
  double CurrentThetaValue;

  double CurrentXVelocity;
  double CurrentYVelocity;
  double CurrentRVelocit;

  double MaxXVelocity;
  double MaxYVelocity;
  double MaxRVelocity;
} Robot_Telemetry;

Robot_Telemetry ricky = {
  .MaxRVelocity = 0
};

//ricky.MaxRVelocity = 0;

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
  
  ricky.MaxRVelocity = 0;
}
3 Likes

Thanks. The misspelling certainly didn’t help, but I would have never guessed it had to be inside a function to work based on the error. Guess I’m too used to python…