足回り動かすためのライブラリ

使用例

#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();
}
}
Committer:
hamohamo
Date:
Fri Oct 29 09:20:31 2021 +0000
Revision:
11:80800fd9f4af
Parent:
1:59244694c2bb
asd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hamohamo 0:0a9ce35078a3 1 #ifndef take_encoder
hamohamo 0:0a9ce35078a3 2 #define take_encoder
hamohamo 0:0a9ce35078a3 3
hamohamo 0:0a9ce35078a3 4 #include "mbed.h"
hamohamo 0:0a9ce35078a3 5
hamohamo 0:0a9ce35078a3 6 #ifndef M_PI
hamohamo 0:0a9ce35078a3 7 #define M_PI 3.14159265358979
hamohamo 0:0a9ce35078a3 8 #endif
hamohamo 1:59244694c2bb 9 /*INFO
hamohamo 1:59244694c2bb 10 *coreを使わない場合idは何でもいいです
hamohamo 1:59244694c2bb 11 *タイヤの角度~角加加速度まで一応計測できます
hamohamo 1:59244694c2bb 12 *単位はrad~rad/s³
hamohamo 1:59244694c2bb 13 */
hamohamo 0:0a9ce35078a3 14 class Encoder{
hamohamo 0:0a9ce35078a3 15 public:
hamohamo 0:0a9ce35078a3 16 Encoder(PinName pinA,PinName pinB,int resolution,int mode,int id);
hamohamo 0:0a9ce35078a3 17 ~Encoder();
hamohamo 0:0a9ce35078a3 18 void Update(double dt);
hamohamo 0:0a9ce35078a3 19 double get_Theta();
hamohamo 0:0a9ce35078a3 20 double get_Omega();
hamohamo 0:0a9ce35078a3 21 double get_Alpha();
hamohamo 0:0a9ce35078a3 22 double get_Jerk();
hamohamo 0:0a9ce35078a3 23 double get_ID();
hamohamo 0:0a9ce35078a3 24 long long int pulse;
hamohamo 0:0a9ce35078a3 25 private:
hamohamo 0:0a9ce35078a3 26 InterruptIn *pin_A;
hamohamo 0:0a9ce35078a3 27 InterruptIn *pin_B;
hamohamo 0:0a9ce35078a3 28 double theta[2];
hamohamo 0:0a9ce35078a3 29 double omega[2];
hamohamo 0:0a9ce35078a3 30 double alpha[2];
hamohamo 0:0a9ce35078a3 31 double jerk;
hamohamo 0:0a9ce35078a3 32
hamohamo 0:0a9ce35078a3 33 int resolution;
hamohamo 0:0a9ce35078a3 34 int mode;
hamohamo 0:0a9ce35078a3 35
hamohamo 0:0a9ce35078a3 36 void init();
hamohamo 0:0a9ce35078a3 37 void riseA(void);
hamohamo 0:0a9ce35078a3 38 void riseB(void);
hamohamo 0:0a9ce35078a3 39 void fallA(void);
hamohamo 0:0a9ce35078a3 40 void fallB(void);
hamohamo 0:0a9ce35078a3 41 int ID;
hamohamo 0:0a9ce35078a3 42 };
hamohamo 0:0a9ce35078a3 43
hamohamo 0:0a9ce35078a3 44 #endif