Support for smooth acceleration/deceleration in run (#900)
* removed logging * removing more logging * always use step for single/multiple motors * refactored schedule * account for accel ramp up and down * added default acc/decel * rounding speed/angle * remove hack * use acceleration time in run too * handle missing case * adding notes on motors * adding sample * fixed ramp simulation * clear defaults * some docs, more later * adding basic examples * remove debug msg * clean json * added move schedule * docs * basic docs
This commit is contained in:
@ -6,9 +6,9 @@ Set the rotation speed of the motor as a percentage of maximum speed.
|
||||
motors.largeA.run(50)
|
||||
```
|
||||
|
||||
The speed setting is a pecentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
|
||||
The speed setting is a percentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
|
||||
|
||||
If you use just the **speed** number, the motor runs continously and won't stop unless you tell it to. You can also give a value for a certain amount of distance you want the motor to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations.
|
||||
If you use just the **speed** number, the motor runs continuously and won't stop unless you tell it to. You can also give a value for a certain amount of distance you want the motor to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations.
|
||||
|
||||
If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**.
|
||||
|
||||
@ -30,8 +30,8 @@ Here is how you use each different movement unit to run the motor for a fixed ro
|
||||
// Run motor for 700 Milliseconds.
|
||||
motors.largeA.run(25, 700, MoveUnit.MilliSeconds);
|
||||
|
||||
// Run motor for 700 Milliseconds again but no units specified.
|
||||
motors.largeA.run(25, 700);
|
||||
// Run motors B and C for 700 Milliseconds again but no units specified.
|
||||
motors.largeBC.run(25, 700);
|
||||
|
||||
// Run the motor for 45 seconds
|
||||
motors.largeA.run(50, 45, MoveUnit.Seconds);
|
||||
@ -61,6 +61,14 @@ motors.largeB.run(-25)
|
||||
|
||||
## ~
|
||||
|
||||
## Multiple motors
|
||||
|
||||
When using **run** with multiple motors, there is no guarantee that their speed will stay in sync. Use [tank](/reference/motors/tank) or [steer](/reference/motors/steer) for synchronized motor operations.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.run(50)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Drive the motor for 20 seconds
|
||||
|
22
docs/reference/motors/motor/schedule.md
Normal file
22
docs/reference/motors/motor/schedule.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Schedule
|
||||
|
||||
Schedules an acceleration, constant and deceleration phase at a given speed.
|
||||
|
||||
```sig
|
||||
motors.largeA.schedule(50, 100, 500, 100)
|
||||
```
|
||||
|
||||
The speed setting is a percentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
* **speed**: a [number](/types/number) that is the percentage of full speed. A negative value runs the motor in the reverse direction.
|
||||
* **acceleration**: the [number](/types/number) of movement units to rotate for while accelerating.
|
||||
* **value**: the [number](/types/number) of movement units to rotate for.
|
||||
* **deceleration**: the [number](/types/number) of movement units to rotate for while decelerating.
|
||||
* **unit**: the movement unit of rotation. This can be `milliseconds`, `seconds`, `degrees`, or `rotations`. If the number for **value** is `0`, this parameter isn't used.
|
||||
|
||||
## See also
|
||||
|
||||
[tank](/reference/motors/synced/tank), [steer](/reference/motors/synced/steer), [stop](/reference/motors/motor/stop)
|
20
docs/reference/motors/motor/set-run-acceleration-ramp.md
Normal file
20
docs/reference/motors/motor/set-run-acceleration-ramp.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Set Run Acceleration Ramp
|
||||
|
||||
```sig
|
||||
motors.largeD.setRunAccelerationRamp(1, MoveUnit.Seconds)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeB.run(50, 6, MoveUnit.Rotations)
|
||||
})
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeC.run(50, 6, MoveUnit.Seconds)
|
||||
})
|
||||
motors.largeB.setRunAccelerationRamp(360, MoveUnit.Degrees)
|
||||
motors.largeB.setRunDecelerationRamp(360, MoveUnit.Degrees)
|
||||
motors.largeC.setRunAccelerationRamp(2, MoveUnit.Seconds)
|
||||
motors.largeC.setRunDecelerationRamp(2, MoveUnit.Seconds)
|
||||
```
|
20
docs/reference/motors/motor/set-run-deceleration-ramp.md
Normal file
20
docs/reference/motors/motor/set-run-deceleration-ramp.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Set Run Deceleration Ramp
|
||||
|
||||
```sig
|
||||
motors.largeD.setRunDecelerationRamp(1, MoveUnit.Seconds)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeB.run(50, 6, MoveUnit.Rotations)
|
||||
})
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeC.run(50, 6, MoveUnit.Seconds)
|
||||
})
|
||||
motors.largeB.setRunAccelerationRamp(360, MoveUnit.Degrees)
|
||||
motors.largeB.setRunDecelerationRamp(360, MoveUnit.Degrees)
|
||||
motors.largeC.setRunAccelerationRamp(2, MoveUnit.Seconds)
|
||||
motors.largeC.setRunDecelerationRamp(2, MoveUnit.Seconds)
|
||||
```
|
@ -15,7 +15,7 @@
|
||||
"cardType": "tutorial",
|
||||
"url":"/tutorials/touch-sensor-values",
|
||||
"imageUrl":"/static/tutorials/touch-sensor-values.png"
|
||||
},
|
||||
}, {
|
||||
"name": "Pause Until Pressed",
|
||||
"description": "Waits for the sensor to be pressed before continuing the program",
|
||||
"cardType": "tutorial",
|
||||
|
Reference in New Issue
Block a user