Merge branch 'master' into motorslider
This commit is contained in:
commit
10cd39a4ec
@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
"chassis.Chassis": "A differential drive robot",
|
"chassis.Chassis": "A differential drive robot",
|
||||||
"chassis.Chassis.drive": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
|
"chassis.Chassis.drive": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
|
||||||
"chassis.Chassis.driveFor": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
|
|
||||||
"chassis.Chassis.driveFor|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
|
|
||||||
"chassis.Chassis.driveFor|param|speed": "speed of the center point between motors, eg: 10",
|
|
||||||
"chassis.Chassis.driveFor|param|value": "the amount of movement, eg: 2",
|
|
||||||
"chassis.Chassis.drive|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
|
"chassis.Chassis.drive|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
|
||||||
"chassis.Chassis.drive|param|speed": "speed of the center point between motors, eg: 10",
|
"chassis.Chassis.drive|param|speed": "speed of the center point between motors, eg: 10",
|
||||||
|
"chassis.Chassis.drive|param|value": "the amount of movement, eg: 2",
|
||||||
"chassis.Chassis.setMotors": "Sets the motors used by the chassis, default is B+C",
|
"chassis.Chassis.setMotors": "Sets the motors used by the chassis, default is B+C",
|
||||||
"chassis.Chassis.setProperty": "Sets a property of the robot",
|
"chassis.Chassis.setProperty": "Sets a property of the robot",
|
||||||
"chassis.Chassis.setProperty|param|property": "the property to set",
|
"chassis.Chassis.setProperty|param|property": "the property to set",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ChassisProperty.BaseLength|block": "base length (cm)",
|
"ChassisProperty.BaseLength|block": "base length (cm)",
|
||||||
"ChassisProperty.WheelRadius|block": "wheel radius (cm)",
|
"ChassisProperty.WheelRadius|block": "wheel radius (cm)",
|
||||||
"chassis.Chassis.driveFor|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s|for %value|%unit",
|
|
||||||
"chassis.Chassis.drive|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s",
|
"chassis.Chassis.drive|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s",
|
||||||
"chassis.Chassis.setMotors|block": "set %chassis|motors to %motors",
|
"chassis.Chassis.setMotors|block": "set %chassis|motors to %motors",
|
||||||
"chassis.Chassis.setProperty|block": "set %chassis|%property|to %value",
|
"chassis.Chassis.setProperty|block": "set %chassis|%property|to %value",
|
||||||
|
@ -24,19 +24,6 @@ namespace chassis {
|
|||||||
this.baseLength = 12;
|
this.baseLength = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
|
||||||
* using a unicycle model.
|
|
||||||
* @param speed speed of the center point between motors, eg: 10
|
|
||||||
* @param rotationSpeed rotation of the robot around the center point, eg: 30
|
|
||||||
*/
|
|
||||||
//% blockId=motorDrive block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s"
|
|
||||||
//% inlineInputMode=inline
|
|
||||||
//% weight=99 blockGap=8
|
|
||||||
drive(speed: number, rotationSpeed: number) {
|
|
||||||
this.driveFor(speed, rotationSpeed, 0, MoveUnit.Degrees);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
||||||
* using a unicycle model.
|
* using a unicycle model.
|
||||||
@ -45,10 +32,10 @@ namespace chassis {
|
|||||||
* @param value the amount of movement, eg: 2
|
* @param value the amount of movement, eg: 2
|
||||||
* @param unit
|
* @param unit
|
||||||
*/
|
*/
|
||||||
//% blockId=motorDriveFor block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s|for %value|%unit"
|
//% blockId=motorDrive block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s"
|
||||||
//% inlineInputMode=inline
|
//% inlineInputMode=inline
|
||||||
//% weight=95 blockGap=8
|
//% weight=95 blockGap=8
|
||||||
driveFor(speed: number, rotationSpeed: number, value: number, unit: MoveUnit) {
|
drive(speed: number, rotationSpeed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||||
// speed is expressed in %
|
// speed is expressed in %
|
||||||
const R = this.wheelRadius; // cm
|
const R = this.wheelRadius; // cm
|
||||||
const L = this.baseLength; // cm
|
const L = this.baseLength; // cm
|
||||||
@ -65,7 +52,7 @@ namespace chassis {
|
|||||||
const sr = vr / maxw * 100; // %
|
const sr = vr / maxw * 100; // %
|
||||||
const sl = vl / maxw * 100; // %
|
const sl = vl / maxw * 100; // %
|
||||||
|
|
||||||
this.motors.tankFor(sr, sl, value, unit)
|
this.motors.tank(sr, sl, value, unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"sensors.ColorSensor.onLightChanged|block": "on %sensor|%mode|%condition",
|
"sensors.ColorSensor.onLightChanged|block": "on %sensor|%mode|%condition",
|
||||||
"sensors.ColorSensor.pauseForColor|block": "pause %sensor|for color %color",
|
"sensors.ColorSensor.pauseForColor|block": "pause %sensor|for color %color",
|
||||||
"sensors.ColorSensor.pauseForLight|block": "pause %sensor|for %mode|%condition",
|
"sensors.ColorSensor.pauseForLight|block": "pause %sensor|for %mode|%condition",
|
||||||
"sensors.ColorSensor.setThreshold|block": "set %condition|to %value",
|
"sensors.ColorSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||||
"sensors.color1|block": "color 1",
|
"sensors.color1|block": "color 1",
|
||||||
"sensors.color2|block": "color 2",
|
"sensors.color2|block": "color 2",
|
||||||
"sensors.color3|block": "color 3",
|
"sensors.color3|block": "color 3",
|
||||||
|
@ -227,8 +227,9 @@ namespace sensors {
|
|||||||
* @param condition the dark or bright light condition
|
* @param condition the dark or bright light condition
|
||||||
* @param value the value threshold
|
* @param value the value threshold
|
||||||
*/
|
*/
|
||||||
//% blockId=colorSetThreshold block="set %condition|to %value"
|
//% blockId=colorSetThreshold block="set %sensor|%condition|to %value"
|
||||||
//% group="Threshold" blockGap=8 weight=90
|
//% group="Threshold" blockGap=8 weight=90
|
||||||
|
//% value.min=0 value.max=100
|
||||||
setThreshold(condition: LightCondition, value: number) {
|
setThreshold(condition: LightCondition, value: number) {
|
||||||
if (condition == LightCondition.Dark)
|
if (condition == LightCondition.Dark)
|
||||||
this.thresholdDetector.setLowThreshold(value)
|
this.thresholdDetector.setLowThreshold(value)
|
||||||
|
@ -216,10 +216,17 @@ namespace motors {
|
|||||||
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||||
this.init();
|
this.init();
|
||||||
speed = Math.clamp(-100, 100, speed >> 0);
|
speed = Math.clamp(-100, 100, speed >> 0);
|
||||||
|
// stop if speed is 0
|
||||||
if (!speed) {
|
if (!speed) {
|
||||||
this.stop();
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// special: 0 is infinity
|
||||||
|
if (value == 0) {
|
||||||
|
this._setSpeed(speed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// timed motor moves
|
||||||
let useSteps: boolean;
|
let useSteps: boolean;
|
||||||
let stepsOrTime: number;
|
let stepsOrTime: number;
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
@ -242,6 +249,8 @@ namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._move(useSteps, stepsOrTime, speed);
|
this._move(useSteps, stepsOrTime, speed);
|
||||||
|
// wait till motor is done with this work
|
||||||
|
this.pauseUntilReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"sensors.InfraredSensor.pauseUntil|block": "pause until %sensor| %event",
|
"sensors.InfraredSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||||
"sensors.InfraredSensor.proximity|block": "%sensor|proximity",
|
"sensors.InfraredSensor.proximity|block": "%sensor|proximity",
|
||||||
"sensors.InfraredSensor.remoteCommand|block": "%sensor|remote command",
|
"sensors.InfraredSensor.remoteCommand|block": "%sensor|remote command",
|
||||||
"sensors.InfraredSensor.setThreshold|block": "set %condition|to %value",
|
"sensors.InfraredSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||||
"sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed",
|
"sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed",
|
||||||
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event",
|
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event",
|
||||||
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed",
|
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed",
|
||||||
|
@ -257,8 +257,9 @@ namespace sensors {
|
|||||||
* @param condition the dark or bright light condition
|
* @param condition the dark or bright light condition
|
||||||
* @param value the value threshold
|
* @param value the value threshold
|
||||||
*/
|
*/
|
||||||
//% blockId=irSetThreshold block="set %condition|to %value"
|
//% blockId=irSetThreshold block="set %sensor|%condition|to %value"
|
||||||
//% group="Threshold" blockGap=8
|
//% group="Threshold" blockGap=8
|
||||||
|
//% value.min=0 value.max=100
|
||||||
setThreshold(condition: InfraredSensorEvent, value: number) {
|
setThreshold(condition: InfraredSensorEvent, value: number) {
|
||||||
if (condition == InfraredSensorEvent.ObjectNear)
|
if (condition == InfraredSensorEvent.ObjectNear)
|
||||||
this.proximityThreshold.setLowThreshold(value)
|
this.proximityThreshold.setLowThreshold(value)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"sensors.UltraSonicSensor.distance|block": "%sensor|distance",
|
"sensors.UltraSonicSensor.distance|block": "%sensor|distance",
|
||||||
"sensors.UltraSonicSensor.onEvent|block": "on %sensor|%event",
|
"sensors.UltraSonicSensor.onEvent|block": "on %sensor|%event",
|
||||||
"sensors.UltraSonicSensor.pauseUntil|block": "pause until %sensor| %event",
|
"sensors.UltraSonicSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||||
"sensors.UltraSonicSensor.setThreshold|block": "set %condition|to %value",
|
"sensors.UltraSonicSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||||
"sensors.ultrasonic1|block": "ultrasonic 1",
|
"sensors.ultrasonic1|block": "ultrasonic 1",
|
||||||
"sensors.ultrasonic2|block": "ultrasonic 2",
|
"sensors.ultrasonic2|block": "ultrasonic 2",
|
||||||
"sensors.ultrasonic3|block": "ultrasonic 3",
|
"sensors.ultrasonic3|block": "ultrasonic 3",
|
||||||
|
@ -92,8 +92,9 @@ namespace sensors {
|
|||||||
* @param condition the dark or bright light condition
|
* @param condition the dark or bright light condition
|
||||||
* @param value the value threshold
|
* @param value the value threshold
|
||||||
*/
|
*/
|
||||||
//% blockId=ultrasonicSetThreshold block="set %condition|to %value"
|
//% blockId=ultrasonicSetThreshold block="set %sensor|%condition|to %value"
|
||||||
//% group="Threshold" blockGap=8
|
//% group="Threshold" blockGap=8
|
||||||
|
//% value.min=0 value.max=255
|
||||||
setThreshold(condition: UltrasonicSensorEvent, value: number) {
|
setThreshold(condition: UltrasonicSensorEvent, value: number) {
|
||||||
switch(condition) {
|
switch(condition) {
|
||||||
case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
|
case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
|
||||||
|
Loading…
Reference in New Issue
Block a user