Okapi Rotation Sensor Reset Not Working

Hello, I have been having problems with resetting the rotation sensors’ reading to 0. My code is essentially just calling the okapi rotation sensor’s reset() function. However, this does not actually seem to do anything. Do I need to do something else to actually reset it or is it just broken? I know this is not a lot of info to work off of, so if anyone needs more info, just let me know and I will answer any questions. Thanks.

there is a reset_position method for resetting the position of the rotation sensor to zero.

Correct, there is a reset_position method in PROS that resets the rotation sensor’s position. I am using Okapi, but it should be the same as using the reset_position in PROS because looking at Okapi’s source code for the rotation sensor, we can see that the reset method is simply calling the PROS reset method.

std::int32_t RotationSensor::reset() {
    return pros::c::rotation_reset(port);
}

Looking at the PROS source code, it is just calling the VexCode one, so it makes me believe its a problem with VexCode itself.

int32_t rotation_reset_position(uint8_t port) {
	claim_port_i(port - 1, E_DEVICE_ROTATION);
	vexDeviceAbsEncPositionSet(device->device_info, 0);
	return_port(port - 1, PROS_SUCCESS);
}

I have not tested with VexCode, so that will probably be my next step, but temporarily for now, I have simply subtracted the initial/absolute value that the rotation sensor starts at to make it seem as if it starts at 0.

I have found the problem, which is that Okapi’s rotation sensor calls the wrong PROS function. It should call pros::c::rotation_reset_position();, but it only calls the rotation_reset(). I have now changed to PROS’ rotation sensor class and it works great.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.