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.
Fork of omuni by
Revision 6:60f122986f29, committed 2017-10-25
- Comitter:
- gaku_sigu
- Date:
- Wed Oct 25 08:53:17 2017 +0000
- Parent:
- 5:5133533ed6d2
- Child:
- 7:76e11784ce6b
- Commit message:
- bobo
Changed in this revision
| P_motor.lib | Show annotated file Show diff for this revision Revisions of this file |
| omuni.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/P_motor.lib Mon Oct 16 09:57:14 2017 +0000 +++ b/P_motor.lib Wed Oct 25 08:53:17 2017 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/fujikenac/code/P_motor/#9d893f55d17f +https://os.mbed.com/users/fujikenac/code/P_motor/#483f189d3508
--- a/omuni.cpp Mon Oct 16 09:57:14 2017 +0000
+++ b/omuni.cpp Wed Oct 25 08:53:17 2017 +0000
@@ -1,6 +1,6 @@
#include "omuni.h"
-
-
+
+
int8_t omuni::map(int8_t in, int8_t inMin, int8_t inMax, int8_t outMin, int8_t outMax)
{
// check it's within the range
@@ -20,8 +20,8 @@
// calculate the output.
return int8_t(outMin + scale*float(outMax-outMin));
}
-
-
+
+
omuni::omuni(I2C* i2c_,int8_t addr1,int8_t addr2,int8_t addr3, double delta)
:i2c(i2c_),m1(i2c_,addr1),m2(i2c_,addr2),m3(i2c_,addr3)
{
@@ -52,15 +52,23 @@
if((sieta1 < -PI/3 && sieta1 > -2*PI/3.0))
w = -PI/3;
}
- float s1 = r2*float(sin(alpha)*-x2*0.01) + float(L*w);
- float s2 = r2*float(sin(alpha+4.0/3*PI)*-x2 - cos(alpha+4.0/3*PI)*y2)*0.01 + float(L*w);
- float s3 = r2*float(sin(alpha+2.0/3*PI)*-x2 - cos(alpha+2.0/3*PI)*y2)*0.01 + float(L*w);
- m1 = s1;
- m2 = s2;
- m3 = s3;
- m1.run();
- m2.run();
- m3.run();
+
+ if(r2)
+ {
+ m1 = r2*float(sin(alpha)*-x2*0.01) + float(L*w);
+ m2 = r2*float(sin(alpha+4.0/3*PI)*-x2 - cos(alpha+4.0/3*PI)*y2)*0.01 + float(L*w);
+ m3 = r2*float(sin(alpha+2.0/3*PI)*-x2 - cos(alpha+2.0/3*PI)*y2)*0.01 + float(L*w);
+ m1.run();
+ m2.run();
+ m3.run();
+ }
+ else
+ {
+ float spdt = 0.5f * float(L*w);
+ m1.direct_controll(spdt);
+ m2.direct_controll(spdt);
+ m3.direct_controll(spdt);
+ }
//printf("%5.2f : %5.2f : %5.2f : %5.2f",(float)x2,(float)y2,sieta1*180/PI,r1);
//printf("\n");
}
\ No newline at end of file
