足回り動かすためのライブラリ
使用例
#include "scrp_slave.hpp" #include "core.hpp" #include "mbed.h" ScrpSlave sendpwm(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807f800); Robot AKASHIKOSEN(50.8,25.4,322.5,259.75); Core RBT(&AKASHIKOSEN,OMNI4,0.02); int main(){ /*--------------SETUP--------------*/ AKASHIKOSEN.setCWID(0,1,2,3); AKASHIKOSEN.setSWID(4,5,6,7); RBT.addENC(PC_4,PA_13,512,4,0); RBT.addENC(PA_14,PA_15,512,4,1); RBT.addENC(PC_2,PC_3,512,4,2); RBT.addENC(PC_10,PC_11,512,4,3); RBT.addENC(PA_7,PA_6,512,4,4); RBT.addENC(PA_9,PA_8,512,4,5); RBT.addENC(PC_1,PC_0,512,4,6); RBT.addENC(PC_5,PA_12,512,4,7); RBT.START(); /*--------------LOOP--------------*/ Position pos; while(true){ pos = RBT.getStatus(); printf("x:%lf,y:%lf,theta:%lf\n",pos.x,pos.y,pos.theta); RBT.LOOP(); } }
Diff: core.cpp
- Revision:
- 3:3f42230ca4ec
- Parent:
- 2:d88ff6dda390
- Child:
- 4:2425cd08e0c2
--- a/core.cpp Wed Oct 13 08:12:34 2021 +0000 +++ b/core.cpp Wed Oct 13 08:47:03 2021 +0000 @@ -1,6 +1,6 @@ #include "core.hpp" -Core::Core(Robot* robot,int mode,double dt):rbt(robot),mode(mode),dt(dt),Mots(4),Encs(8),PIDs(5){} +Core::Core(Robot* robot,int mode,double dt):rbt(robot),mode(mode),dt(dt),Mots(5),Encs(9),PIDs(6){} Motor* Core::addMOT(PinName plus,PinName minus,int period,int id){ Mots.at(id) = new Motor(plus,minus,period,id); return Mots.at(id); @@ -131,11 +131,11 @@ PIDs[rbt->LF]->Update(Encs[rbt->LF]->get_Omega(),w4/rbt->CWR,dt); //printf("%lf,%lf\n",Encs[rbt->LF]->get_Omega(),w4/rbt->CWR); WAIT(0.01); - sendPWM(PIDs[rbt->RF]->getGain(),rbt->RF+1); + sendPWM(PIDs[rbt->RF]->getGain(),rbt->RF); WAIT(0.0125); - sendPWM(PIDs[rbt->RB]->getGain(),rbt->RB+1); + sendPWM(PIDs[rbt->RB]->getGain(),rbt->RB); WAIT(0.015); - sendPWM(PIDs[rbt->LB]->getGain(),rbt->LB+1); + sendPWM(PIDs[rbt->LB]->getGain(),rbt->LB); WAIT(0.0175); - sendPWM(PIDs[rbt->LF]->getGain(),rbt->LF+1); + sendPWM(PIDs[rbt->LF]->getGain(),rbt->LF); } \ No newline at end of file