NHK2017 octopus robot

Dependencies:   2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel

Fork of KANI2017v2 by NagaokaRoboticsClub_mbedTeam

bot/wheel_unit/wheel_unit.cpp

Committer:
number_key
Date:
2017-09-13
Revision:
24:9a4ca5442717
Parent:
23:37bb9afe9fdc
Child:
25:d199d621ecca

File content as of revision 24:9a4ca5442717:

#include "wheel_unit.h"

WheelUnit::WheelUnit(DigitalOut* RS485Controller, Serial* RS485) :
	Omni(4),
	wheels({
		{RS485Controller, 0, 0, SM, RS485},
		{RS485Controller, 0, 1, SM, RS485},
		{RS485Controller, 0, 2, SM, RS485},
		{RS485Controller, 0, 3, SM, RS485}
	})
{
	Omni::setWheelRadian(PI / 4.0, 3 * PI / 4.0, 5 * PI / 4.0, 7 * PI / 4.0);
	//Omni::setWheelRadian(PI / 4.0, PI / 4.0, PI / 4.0, PI / 4.0);
	for(int i = 0; i < 4; i++) {
		wheels[i].braking = true;
	}
}

void WheelUnit::moveXY(float X, float Y, float moment)
{
	Omni::computeXY(X, Y, moment);
	for(int i = 0; i < 4; i++) {
		wheels[i].setSpeed(Omni::getOutput(i));
	}
}

void WheelUnit::moveCircular(float r, float radian, float moment)
{
	Omni::computeCircular(r, radian, moment);
	for(int i = 0; i < 4; i++) {
		wheels[i].setSpeed(Omni::getOutput(i));
	}
}