This program is for an autonomous robot for the competition at the Hochschule Luzern. http://cruisingcrepe.wordpress.com/ We are one of the 32 teams. http://cruisingcrepe.wordpress.com/ The postition control is based on this Documentation: Control of Wheeled Mobile Robots: An Experimental Overview from Alessandro De Luca, Giuseppe Oriolo, Marilena Vendittelli. For more information see here: http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf

Dependencies:   mbed

Fork of autonomous Robot Android by Christian Burri

RobotControl/MotionState.cpp

Committer:
chrigelburri
Date:
2013-03-23
Revision:
6:48eeb41188dd
Parent:
0:31f7be68e52d
Child:
11:775ebb69d5e1

File content as of revision 6:48eeb41188dd:

#include "MotionState.h"

using namespace std;

MotionState::MotionState()
{
    xposition = 0.0f;
    yposition = 0.0f;
    theta = 0.0f;
    thetaCompass = 0.0f;
    speed = 0.0f;
    omega = 0.0f;

    acceleration = ACCELERATION;
    thetaAcceleration = THETA_ACCELERATION;
}


MotionState::MotionState(float xposition,
                         float yposition,
                         float theta,
                         float speed,
                         float omega)
{
    this->xposition = xposition;
    this->yposition = yposition;
    this->theta = theta;
    this->speed = speed;
    this->omega = omega;
    acceleration = ACCELERATION;
    thetaAcceleration = THETA_ACCELERATION;
}

MotionState::~MotionState()
{

}

void MotionState::setState(float xposition,
                           float yposition,
                           float theta,
                           float speed,
                           float omega)
{
    this->xposition = xposition;
    this->yposition = yposition;
    this->theta = theta;
    this->speed = speed;
    this->omega = omega;
}

void MotionState::setState(MotionState* motionState)
{
    xposition = motionState->xposition;
    yposition = motionState->yposition;
    theta = motionState->theta;
    speed = motionState->speed;
    omega = motionState->omega;
}

void MotionState::setxPosition(float xposition)
{
    this->xposition = xposition;
}

float MotionState::getxPosition()
{
    return xposition;
}

void MotionState::setyPosition(float yposition)
{
    this->yposition = yposition;
}

float MotionState::getyPosition()
{
    return yposition;
}

void MotionState::setTheta(float theta)
{
    this->theta = theta;
}

float MotionState::getTheta()
{
    return theta;
}

void MotionState::setSpeed(float speed)
{
    this->speed = speed;
}

float MotionState::getSpeed()
{
    return speed;
}

void MotionState::setOmega(float omega)
{
    this->omega = omega;
}

float MotionState::getOmega()
{
    return omega;
}

void MotionState::setAcceleration(float acceleration)
{
    this->acceleration = acceleration;
}

float MotionState::getAcceleration()
{
    return acceleration;
}

void MotionState::setThetaAcceleration(float thetaAcceleration)
{
    this->thetaAcceleration = thetaAcceleration;
}

float MotionState::getThetaAcceleration()
{
    return thetaAcceleration;
}

void MotionState::increment(float desiredSpeed,
                            float desiredOmega,
                            float period)
{
    float acceleration = (desiredSpeed-speed)/period;
    if (acceleration < -this->acceleration) acceleration = -this->acceleration;
    else if (acceleration > this->acceleration) acceleration = this->acceleration;

    float thetaAcceleration = (desiredOmega-omega)/period;
    if (thetaAcceleration < -this->thetaAcceleration) thetaAcceleration = -this->thetaAcceleration;
    else if (thetaAcceleration > this->thetaAcceleration) thetaAcceleration = this->thetaAcceleration;

    speed += acceleration * period;
    omega += thetaAcceleration * period;
}