PROS memory permission error 00000000

#1

I am trying to use okapi but when I run my code on the brain there is a pop up that says, “memory permission error 00000000”. The error occurs when I try to use tank drive in okapi. This error does not occur when I comment out the line -
drive.tank(controller1.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y),
controller1.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));

What causes this error and how can I fix it.

edit: it also occurs anytime I try to control the drive using okapi, except when doing autonomous.

0 Likes

#2

That’s strange. Memory permission error (aka segfault) can be caused by a few things.

  1. Division by 0
  2. Accessing an array element out of bounds
  3. Using an invalid pointer
  4. Passing a wrong type to a function
  5. Any other run-time error the compiler does not catch

I might have an idea what is causing your error. If you look at the okapi documentation for tank https://pros.cs.purdue.edu/v5/okapi/api/chassis/controller/abstract-chassis-controller.html#id22
You can see that it accepts values in the range [-1, 1]. Likewise, if you look at the documentation for the okapi Controller getAnalog https://pros.cs.purdue.edu/v5/okapi/api/device/controller.html#getanalog you can see it also outputs in the range of [-1, 1]. The reason okapi chose to use that range is because it represents a percentage instead of an arbitrary number.
However, in your code above, you are not using an okapi Controller, you are using a pros Controller. Looking at that documentation https://pros.cs.purdue.edu/v5/api/cpp/misc.html#get-analog, you can see it outputs values from the range of [-127, 127], which is not compatible with okapi. The solution might be to switch to using an okapi Controller like this:

drive.tank(controller.getAnalog(ControllerAnalog::leftY),
controller.getAnalog(ControllerAnalog::rightY));

I am not convinced that is what is causing the segfault, but give it a try.
If that does not solve the issue, can you show us where you define and create your chassis and controller?

1 Like

#3

I tried that, but it did not correct the issue. I have switched to not using okapi because I was frustrated with it.

0 Likes