Hi, so Im programming and I am running into this error. no matching function for ‘setDrive’. I defined the function in my header file, and included it in main.h
this is what it says in my setDrive funciton
void setDrive( int lateral, int linear, int rotation ) {
lateral = controller.get_analog (pros::E_CONTROLLER_ANALOG_LEFT_X);
linear = controller.get_analog (pros::E_CONTROLLER_ANALOG_LEFT_Y);
rotation = controller.get_analog (pros::E_CONTROLLER_ANALOG_RIGHT_X);
// Y component, X component, Rotation
topLeftDrive = ( -linear - lateral - rotation);
topRightDrive = ( linear - lateral - rotation);
backLeftDrive = ( linear + lateral - rotation);
backRightDrive = ( -linear + lateral - rotation);
if (abs( lateral ) < 10) {
lateral = 0 ;
}
if (abs( linear ) < 10) {
linear = 0 ;
}
if (abs( rotation ) < 10) {
rotation = 0 ;
}
}
and this is what I have in my opcontrol.
#include "main.h"
void opcontrol() {
setDrive();
pros::delay(20);
}
The problem is in opcontrol. Your function setDrive( int lateral, int linear, int rotation )
requires three inputs. In opcontrol, you didn’t provide any inputs. Since you didn’t the complier is treating setDrive()
as a different function which doesn’t exist. Add your inputs and it should work.
3 Likes
close but not quite. I’m talking about actual numbers for the function. For example
setDrive(10, 0, 90);
This is the part where you actually apply the function you have programmed.
1 Like
oh ok, i understnad what you mean
but I want those values to change, like the controller joystickX = lateral and stuff does it affect it or can i just set everything to 0
So do I understand correctly that this is a driver control drivetrain function? If that is the case, you need to instruct the opcontrol function to continuously run this function. To do this, you will want a while
loop in the opcontrol function.
To do this code it should look something like,
void opcontrol() {
while(true)
{
// read controller inputs, store in variables
// your drivetrain function, pass the inputs
}
}
Have a look at the opcontrol function from this tutorial for a bit more information
2 Likes
yeah I forgot about that, oops