forked from sharpbrick/powered-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleCalibrationSteering.cs
31 lines (22 loc) · 1 KB
/
ExampleCalibrationSteering.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using SharpBrick.PoweredUp;
using SharpBrick.PoweredUp.Functions;
using static SharpBrick.PoweredUp.Directions;
namespace Example;
public class ExampleCalibrationSteering : BaseExample
{
public override async Task ExecuteAsync()
{
using var technicMediumHub = Host.FindByType<TechnicMediumHub>();
var motor = technicMediumHub.A.GetDevice<TechnicLargeLinearMotor>();
var calibration = ServiceProvider.GetService<LinearMidCalibration>();
await calibration.ExecuteAsync(motor);
await technicMediumHub.WaitButtonClickAsync();
await motor.GotoPositionAsync(CW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await technicMediumHub.WaitButtonClickAsync();
await motor.GotoPositionAsync(CCW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
await Task.Delay(5000);
await technicMediumHub.SwitchOffAsync();
}
}