omniwheel lib
Dependents: NHK2017_octopus NHK2017_octopus2 NHK2017_octopus2_drive 2018NHK_gakugaku_robo ... more
Diff: wheel.cpp
- Revision:
- 0:952a0ff1bf46
- Child:
- 1:e9b590a5b27a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wheel.cpp Thu Sep 14 05:51:25 2017 +0000 @@ -0,0 +1,83 @@ +#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; +} \ No newline at end of file