Single tank (#891)

* add note about dual blocks

* fix simulator to match hardware

* updated wording
This commit is contained in:
Peli de Halleux 2019-08-29 13:11:01 -07:00 committed by GitHub
parent bcb682b602
commit a302bbfc2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 0 deletions

View File

@ -39,6 +39,13 @@ motors.largeBC.steer(-15, -75)
## ~
## ~ hint
Only one set of synchronized motors will run at the same time. Once you launch tank/steer, it will cancel any existing synchronized speed command.
## ~
## Examples
### Make a slight right

View File

@ -35,6 +35,12 @@ motors.largeBC.tank(-75, -75)
## ~
## ~ hint
Only one set of synchronized motors will run at the same time. Once you launch tank/steer, it will cancel any existing synchronized speed command.
## ~
## Examples
### Tank forward and backward

View File

@ -65,6 +65,11 @@ namespace pxsim {
delete this._synchedMotor;
}
clearSyncCmd() {
if (this._synchedMotor)
this.clearSpeedCmd();
}
setLarge(large: boolean) {
this.id = large ? NodeType.LargeMotor : NodeType.MediumMotor;
// large 170 rpm (https://education.lego.com/en-us/products/ev3-large-servo-motor/45502)

View File

@ -80,6 +80,12 @@ namespace pxsim {
const brake = pxsim.BufferMethods.getNumber(buf, BufferMethods.NumberFormat.Int8LE, 12);
const motors = ev3board().getMotor(port);
// cancel any other sync command
for(const motor of ev3board().getMotors().filter(motor => motors.indexOf(motor) < 0)) {
motor.clearSyncCmd()
}
// apply commands to all motors
for (const motor of motors) {
const otherMotor = motors.filter(m => m.port != motor.port)[0];
motor.setSyncCmd(