RTOS Threads inside object

12 Apr 2012

I have a body object that has a sensor. The idea that is in the constructor the body should start a new thread that uses basic body functions to constantly monitor and update sensor date

/*
 * Constructor
 */
Body::Body() {
    l_leg = new Leg( p21, p22, p23, LEFT );
    r_leg = new Leg( p24, p25, p26, RIGHT );
    move_sensor = new minimu9();
    semaphore = new Semaphore( 1 );
    
    speed = 1;
    calibrate();
    wait( 1 );
    
    Thread sensor_thread ( update_sensor  );
}

/*
 * Constantly monitor angle data
 */
void Body::update_sensor( void const *argument ){
    float x, y, z;
    while( 1 ) {
        move_sensor->get_data();
        x = move_sensor->get_roll();
        y = move_sensor->get_pitch();
        z = move_sensor->get_yaw();
        set_angles( x, y, z );
    }
}

/*
 * Update values, lock before writing
 */
void Body::set_angles( float x, float y, float z ) {
        semaphore->wait();
        roll = x;
        pitch = y;
        yaw = z;
        semaphore->release();
}

/*
 * Retrieve the values, lock before grabbing to
 * insure they are not contaminated
 */
 float* Body::get_angles( void ) {
    float angles[3];
    semaphore->wait();
    angles[0] = roll;
    angles[1] = pitch;
    angles[2] = yaw;
    semaphore->release();
    
    return angles;
 }

However every time I get an error saying: "no instance of constructor "rtos::Thread::Thread" matches the argument list" in file "/body.cpp", Line: 15, Col: 41

Line 15, col 41 referring to when I try to create the thread object. Any ideas on how to get this to work? I feel like it is something simple but I do not have a lot of experience with threaded programming.