robert virkus - playing with lego mindstorms from your mobile phone
DESCRIPTION
Learn how interact with LEGO Mindstorms robots in this practice heavy talk. Mindstorms is a really great way to get into robotics programming and you can completely control it from within your app. We look at the options available on iOS, Android and Windows Phone and play around with real robots.TRANSCRIPT
Don’t forget to pair your Mindstorms robot first!
legoev3.codeplex.com Connecting
public async Task ConnectAsync(){
Brick brick = new Brick(new BluetoothCommunication() );await Brick.ConnectAsync();IsConnected = true;
}
legoev3.codeplex.com Direct Commands
public async Task CloseClawsAsync(){
await EnsureIsConnectedAsync();await Brick.DirectCommand.TurnMotorAtPowerAsync(OutputPort.A, 10);
}
legoev3.codeplex.com Batch Commands
public async Task MoveAsync(int leftPower, int rightPower){
await EnsureIsConnectedAsync();Brick.BatchCommand.TurnMotorAtPower(OutputPort.B, leftPower);Brick.BatchCommand.TurnMotorAtPower(OutputPort.C, rightPower);await Brick.BatchCommand.SendCommandAsync();
}
legoev3.codeplex.com Sensor Reading
Brick.BrickChanged += Brick_BrickChanged;
private async void Brick_BrickChanged(object sender, BrickChangedEventArgs e){
if (e.Ports[InputPort.One].SIValue == 1|| e.Ports[InputPort.Two].SIValue == 1){
await Brick.DirectCommand.StopMotorAsync(OutputPort.B | OutputPort.C, true);
}}
legoev3.codeplex.com Sensor Configuration
Brick.Ports[InputPort.One].SetMode(TouchMode.Bumps);await Brick.DirectCommand.ClearChanges(InputPort.One);
legoev3.codeplex.com System Commands
await Brick.SystemCommand.CopyFileAsync("\\devconfu.rsf", "../prjs/Tester/dev.rsf");
do it yourself
0 1
2 bytes
Payload
Size
2 3 4 5
2 bytes
Sequence
1 byte
Cmd
Type
2 bytes
local and
global size
(direct
commands)
6 7 8
1 byte or 2 bytes
Command code
and possibly
sub-command
9…
Command-specific payload
Original Linux source code
github.com/mindboards/ev3sources
C programming
robotc.net/download/lego/
.NET programming
monobrick.dk/software/ev3firmware/
Firmwares
Java programming
lejos.org
2005
-4,600 M
Earth forms
-3,500 M
Life forms
-2,000 M
Complex life forms
-225 until -65 M
Age of dinosaurs
-3 M
Stone age