I am using Vex v5 pro-C++ and trying to get a working odometry on my robot. I finished the code, and it always successfully downloads onto the brain. However, whenever I do a run, timed run, or competition run, I always get a memory error (038043CC). I will leave a zipped file (in form of a link) of our code so you can look at it. Thank you.
https://drive.google.com/file/d/1qpUF7TLuDtbYNxwTe5j_Jew6QmVkBL2K/view?usp=sharing
probably this line of code in main.cpp
double Heading = Drivetrain.heading();
you are using Drivetrain before it has been instantiated.
(and it’s probably not something you want to do anyway, that is, assign the current value of Drivetrain.heading() once to a global variable)
Thanks you, that solved our problem and now our program runs. However, the x and y variables on my Odometry algorithm aren’t changing continuously. It changes once at the very beginning of auton and then stays the same. Is there any solution for that?
If the code still looks like this.
x += changeInDistance * std::cos(Heading * (M_PI / 180));
y += changeInDistance * std::sin(Heading * (M_PI / 180));
then you would need to be updating Heading for each iteration of the loop.
perhaps post the code here so others can help.
Yes I removed the heading variable and changed the Heading to Drivetrain.Heading() because I am using the inertial sensor to get our heading. So I don’t know why the values arent updating. here’s the updated file of the code if you can get a look at it. Thanks. new odom code