Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ActiveCaster_ ActiveCaster_2
Revision 2:f206311600ee, committed 2022-01-28
- Comitter:
- e5119053f6
- Date:
- Fri Jan 28 15:43:18 2022 +0000
- Parent:
- 1:5a65fc20f8c2
- Commit message:
- DDSS
Changed in this revision
| DDSScontrol.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DDSScontrol.cpp Wed Jan 26 11:21:36 2022 +0000
+++ b/DDSScontrol.cpp Fri Jan 28 15:43:18 2022 +0000
@@ -24,7 +24,7 @@
refVz = _refVz;
stear_angle = _stear_angle;
- V_x = refVx - Wp_y * refVz;
+ V_x = refVx - Wp_y * refVz;//操舵点の速度決定
V_y = refVy + Wp_x * refVz;
omega_wheel = (V_x * cos(stear_angle) + V_y * sin(stear_angle)) / WHEEL_R;//操舵角速度
@@ -38,29 +38,16 @@
MD_val_a = fabs(rpm_a) * 0.8 / MAX_RPM+0.1;//ESCONの指令値に変換する処理
MD_val_b = fabs(rpm_b) * 0.8 / MAX_RPM+0.1;
- if(MD_val_a>0.9) {//ESCONのPWM指令は10%から90%の間で有効なのでその範囲に収める処理
- MD_val_a = 0.9;
- } else if(MD_val_a<0.1) {
- MD_val_a=0.1;
- }
- if(MD_val_b>0.9) {
- MD_val_b = 0.9;
- } else if(MD_val_b<0.1) {
- MD_val_b=0.1;
- }
+
+ MD_val_a = MD_val_a > 0.9 ? MD_val_a = 0.9 : MD_val_a;//ESCONのPWM指令は10%から90%の間で有効なのでその範囲に収める処理
+ MD_val_a = MD_val_a < 0.1 ? MD_val_a = 0.1 : MD_val_a;
+ MD_val_b = MD_val_b > 0.9 ? MD_val_b = 0.9 : MD_val_b;
+ MD_val_b = MD_val_b < 0.1 ? MD_val_b = 0.1 : MD_val_b;
- if(rpm_a>0) {
- dir_a.write(1);
- } else {
- dir_a.write(0);
- }
- if(rpm_b>0) {
- dir_b.write(0);
- } else {
- dir_b.write(1);
- }
+ rpm_a > 0 ? dir_a.write(1):dir_a.write(0);//回転方向の指定
+ rpm_b > 0 ? dir_b.write(1):dir_b.write(0);
- pwm_a.write(MD_val_a);
+ pwm_a.write(MD_val_a);//PWM出力処理
pwm_b.write(MD_val_b);
}
\ No newline at end of file