PROS Build Problem

I’m a beginner to PROS and I’m making a very basic exponential drive. Whenever I take the base decimal to the power of a variable, it reads as “invalid operands to the binary expression”. The error is on line 19 and 20. When I try to build an opcontrol file that does not have any errors, it fails. If someone could help with these problems, that would be much appreciated.

#include "main.h"

	 #define LEFTDRIVE_PORT 1,2
	 #define RIGHTDRIVE_PORT 3,4


	void opcontrol() {

	  motor_set_gearing(LEFTDRIVE_PORT, 18) ;
	  motor_set_gearing(RIGHTDRIVE_PORT, 18) ;

		while (true)	{

	    int Joy2 = ((100*(controller_get_analog(1, 2)))/127) ; // percent power from joystick
	    int Joy3 = ((100*(controller_get_analog(1, 3)))/127) ; // percent power from joystick
	    int leftdrive = 0 ;
	    int rightdrive = 0 ;
	    int k = 0 ;
	    int rspeed = floorf((1.038944156^Joy2)-1) ; // takes percent and applies equation
	    int lspeed = floorf((1.038944156^Joy3)-1) ; // takes percent and applies equation

	    if (abs(Joy2) < k) {
	      rightdrive = 0 ;
	    }
	    else if (abs(Joy2) > k) {
	      rightdrive = 12000*rspeed ;
	    }
	    else {
	      rightdrive = 0 ;
	    }

	    if (abs(Joy3) > k) {
	      leftdrive = 0 ;
	    }
	    else if (abs(Joy3) < k) {
	      leftdrive = 12000*lspeed ;
	    }
	    else {
	      leftdrive = 0 ;
	    }

	    motor_move(RIGHTDRIVE_PORT, rightdrive) ;
			motor_move(LEFTDRIVE_PORT, leftdrive) ;

		}
			delay(20);
	}

see this

you are using bitwise xor, not pow function.

1 Like

yeah, ^ is not a power operator.
Instead, it is used for the bitwise operation xor.
If you want power, you can use the std::pow(base, exponent) function.

1 Like

Ok it’s seems to work now. Thanks for the input