omniwheel lib

Dependents:   NHK2017_octopus NHK2017_octopus2 NHK2017_octopus2_drive 2018NHK_gakugaku_robo ... more

wheel.cpp

Committer:
UCHITAKE
Date:
2017-09-14
Revision:
0:952a0ff1bf46
Child:
1:e9b590a5b27a

File content as of revision 0:952a0ff1bf46:

#include "wheel.h"

Wheel::Wheel() :
    radian(0),
    distance(1.0)
{
}

Wheel::Wheel(double radian) :
    radian(radian),
    distance(1.0)
{
}

Wheel::Wheel(double radian, double distance) :
    radian(radian),
    distance(distance)
{
}

Wheel::Wheel(const Wheel &a) :
    radian(a.radian),
    distance(a.distance)
{
}

Wheel &Wheel::operator=(const Wheel &a)
{
    if(this != &a) {
        radian = a.radian;
        distance = a.distance;
    }
    return *this;
}

Wheel &Wheel::operator=(double value)
{
    setOutput(value);
    return *this;
}

Wheel::operator double()
{
    return output;
}

Wheel::operator float()
{
    return float(output);
}

void Wheel::setRadian(double tRadian)
{
    radian = tRadian;
}

void Wheel::setDistance(double tDistance)
{
    distance = tDistance;
}

void Wheel::setOutput(double value)
{
    output = value;
}

double Wheel::calculateShift(double r, double theta)
{
    outputShift = sin(theta + radian) * r;
    return outputShift;
}

double Wheel::calculateRotate(double X, double Y, double value)
{
    outputRotate = fabs(X + tan(radian) * Y - cos(radian) - sin(radian) * tan(radian)) / hypot(1.0, tan(radian));
    outputRotate *= value;
    return outputRotate;
}

double Wheel::getOutput()
{
    return output;
}