Differential drive (#164)

* clear sync speed cmd

* differential drive model

* use cm/s

* fixed aggressive clearing of motor sync command

* better computation of turn artio

* improved robot dimensions

* moving block up

* hanbdle infinite case

* correct handling of inifinte time/step

* better stop handling
This commit is contained in:
Peli de Halleux
2018-01-03 00:27:05 -08:00
committed by GitHub
parent dd9cf9014f
commit 4d223374b5
4 changed files with 96 additions and 28 deletions

View File

@ -80,6 +80,7 @@ namespace pxsim {
stop() {
this.started = false;
this.clearSpeedCmd();
}
start() {
@ -145,14 +146,17 @@ namespace pxsim {
const dstep = this.speedCmd == DAL.opOutputTimeSync
? pxsim.U.now() - this.speedCmdTime
: this.tacho - this.speedCmdTacho;
if (dstep < stepsOrTime)
// 0 is special case, run infinite
if (!stepsOrTime || dstep < stepsOrTime)
this.speed = speed;
else {
if (brake) this.speed = 0;
this.clearSpeedCmd();
}
// send synched motor state
otherMotor.speed = Math.floor(this.speed * turnRatio / 100);
otherMotor.speed = Math.floor(this.speed * turnRatio / 100);
if (!this._synchedMotor)
otherMotor.clearSpeedCmd();
break;
}
}