2022_Ateam_MOTORprogramをscrp_slaveでメインマイコンからコントローラー状況を読み取れるように改良。 また、モータに0以外のpwmが送られている場合に基盤付属のledが点灯するようにした。
Dependencies: SBDBT arrc_mbed BNO055
DUALSHOCKco.cpp@13:369f4abc1f36, 2022-04-08 (annotated)
- Committer:
- guesta
- Date:
- Fri Apr 08 09:14:20 2022 +0000
- Revision:
- 13:369f4abc1f36
- Parent:
- 11:264f992664b0
2022/04/08
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kazumayamanaka | 0:a1238c4cd105 | 1 | #include "DUALSHOCKco.hpp" |
kazumayamanaka | 0:a1238c4cd105 | 2 | |
guesta | 11:264f992664b0 | 3 | void DUALSHOCKco::pass_val(double RSX,double RSY,double R2AN,double L2AN) |
guesta | 11:264f992664b0 | 4 | { |
kazumayamanaka | 0:a1238c4cd105 | 5 | rsx = RSX; |
kazumayamanaka | 0:a1238c4cd105 | 6 | rsy = RSY; |
kazumayamanaka | 0:a1238c4cd105 | 7 | r2an = R2AN; |
kazumayamanaka | 0:a1238c4cd105 | 8 | l2an = L2AN; |
kazumayamanaka | 0:a1238c4cd105 | 9 | } |
kazumayamanaka | 0:a1238c4cd105 | 10 | |
guesta | 11:264f992664b0 | 11 | bool DUALSHOCKco::cal_input() |
guesta | 11:264f992664b0 | 12 | { |
guesta | 11:264f992664b0 | 13 | Xval = (rsx - RS_normal) * 450 / RS_normal; |
guesta | 11:264f992664b0 | 14 | Yval = ((RS_MAX - rsy) - RS_normal + 1) * 450 / RS_normal; |
guesta | 11:264f992664b0 | 15 | if(r2an != 0) { |
guesta | 11:264f992664b0 | 16 | rotate_val = r2an * 400 / RL_MAX; |
guesta | 11:264f992664b0 | 17 | } else { |
guesta | 11:264f992664b0 | 18 | rotate_val = -l2an * 400 / RL_MAX; |
kazumayamanaka | 0:a1238c4cd105 | 19 | } |
guesta | 11:264f992664b0 | 20 | if(r2an == 0 && l2an == 0){ |
guesta | 11:264f992664b0 | 21 | rotate_val = 0; |
guesta | 11:264f992664b0 | 22 | } |
guesta | 11:264f992664b0 | 23 | return false; |
kazumayamanaka | 0:a1238c4cd105 | 24 | } |
kazumayamanaka | 0:a1238c4cd105 | 25 | |
guesta | 11:264f992664b0 | 26 | double DUALSHOCKco::obt_X() |
guesta | 11:264f992664b0 | 27 | { |
guesta | 11:264f992664b0 | 28 | return Xval; |
guesta | 11:264f992664b0 | 29 | } |
kazumayamanaka | 0:a1238c4cd105 | 30 | |
guesta | 11:264f992664b0 | 31 | double DUALSHOCKco::obt_Y() |
guesta | 11:264f992664b0 | 32 | { |
guesta | 11:264f992664b0 | 33 | return Yval; |
guesta | 11:264f992664b0 | 34 | } |
guesta | 11:264f992664b0 | 35 | |
guesta | 11:264f992664b0 | 36 | double DUALSHOCKco::obt_rotate() |
guesta | 11:264f992664b0 | 37 | { |
guesta | 11:264f992664b0 | 38 | return rotate_val; |
guesta | 11:264f992664b0 | 39 | } |