Last active
April 20, 2020 22:04
-
-
Save Vouzamo/65aff0fe2360682caf068edb6dcb4304 to your computer and use it in GitHub Desktop.
LEGO Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var connectionManager = new BluetoothLEConnectionManager()) | |
{ | |
var connectionA = await connectionManager.FindConnectionById("BluetoothLE#BluetoothLEb8:31:b5:93:3c:8c-90:84:2b:4d:d2:62"); | |
var connectionB = await connectionManager.FindConnectionById("BluetoothLE#BluetoothLEb8:31:b5:93:3c:8c-90:84:2b:4e:1b:dd"); | |
var hubA = new TechnicSmartHub(connectionA); | |
var hubB = new TechnicSmartHub(connectionB); | |
// wait until connected | |
await hubA.Connect(); | |
await hubB.Connect(); | |
// wait until all 3 motors are connected to Hub A | |
var leftTrack = await hubA.PortA<TechnicMotorXL>(); | |
var rightTrack = await hubA.PortB<TechnicMotorXL>(); | |
var turntable = await hubA.PortD<TechnicMotorL>(); | |
// wait until all 4 motors are connected to Hub B | |
var primaryBoom = await hubB.PortA<TechnicMotorXL>(); | |
var secondaryBoom = await hubB.PortB<TechnicMotorL>(); | |
var tertiaryBoom = await hubB.PortC<TechnicMotorL>(); | |
var bucket = await hubB.PortD<TechnicMotorL>(); | |
// sequentially calibrate each linear actuator using a torque based range calibration routine | |
await primaryBoom.RunRoutine(new RangeCalibrationRoutine(50)); | |
await secondaryBoom.RunRoutine(new RangeCalibrationRoutine(50)); | |
await tertiaryBoom.RunRoutine(new RangeCalibrationRoutine(40)); | |
await bucket.RunRoutine(new RangeCalibrationRoutine(35)); | |
// move forwards for 5 seconds | |
leftTrack.SetSpeedForDuration(50, 100, RotateDirection.Clockwise, 5000); | |
rightTrack.SetSpeedForDuration(50, 100, RotateDirection.CounterClockwise, 5000); | |
await Task.Delay(5000); | |
// rotate boom for 3 seconds | |
turntable.SetSpeedForDuration(100, 100, RotateDirection.CounterClockwise, 3000); | |
await Task.Delay(3000); | |
// reposition boom | |
primaryBoom.SetSpeedForDuration(100, 100, RotateDirection.Clockwise, 3000); | |
secondaryBoom.SetSpeedForDuration(75, 100, RotateDirection.CounterClockwise, 3000); | |
tertiaryBoom.SetSpeedForDuration(100, 100, RotateDirection.CounterClockwise, 2000); | |
await Task.Delay(3000); | |
// lift bucket | |
bucket.SetSpeedForDuration(50, 100, RotateDirection.Clockwise, 2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment