fixing chassis
This commit is contained in:
parent
951b9be6e4
commit
9912d68c8b
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user