I want to create a thread of the function ahrs thats in my AHRS class. This function is in an infinite loop and calcs something the whole time and puts those calculations in variables. I want to pass those variables to my PID
int main() {
AHRS* a = new AHRS();
std::thread ahrs(a->ahrs());
PID* p = new PID();
float pitch;
while(1) {
pitch = a->getPitch();
std::cout << "pitch: " << pitch << " pid: " << p->getError(0, pitch, 1) << std::endl;
usleep(100000);
}
}
but i get the error
main_ahrs.cpp: In function ‘int main()’:
main_ahrs.cpp:26:28: error: invalid use of void expression
my ahrs.cpp looks like this:
#include "AHRS.h"
AHRS::AHRS() {
//something
}
AHRS::~AHRS() {}
void AHRS::ahrs() {
//something
while(1) {
//something
}
}
float AHRS::getPitch() {
//return something
}
float AHRS::getRoll() {
//return something
}
float AHRS::getYaw() {
//return something
}
thanks for your help