-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (44 loc) · 1.72 KB
/
Program.cs
File metadata and controls
52 lines (44 loc) · 1.72 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Linq;
using System.Net;
using System.Threading;
using RobocupSSLController.Gamepad;
namespace RobocupSSLController
{
class Program
{
static void VisionReceive()
{
Console.WriteLine("Receiving vision packets");
using VisionClient vc = new VisionClient.Builder().Build();
Console.WriteLine("Press any key to stop");
Console.ReadKey();
}
static void RobotControl()
{
var team = RobocupTeam.Yellow;
var robotId = 1;
var robotCount = 8;
using var output = (ICommandsOutput)new GrSimCommandsOutput(team, IPEndPoint.Parse("127.0.0.1:20011"));
using var gamepad = EvDevDeviceInfo.EnumerateDevices()
.Single(_ => _.DevicePath == "/dev/input/event25").OpenGamepad();
var commands = Enumerable.Repeat(RobotCommand.Idle, robotCount).ToArray();
var rnd = new Random();
while (true)
{
Console.WriteLine("{0:#0.000} {1:#0.000} {2:#0.000} {3:#0.000}", gamepad.LeftX.Value, gamepad.LeftY.Value,
gamepad.RightX.Value, gamepad.RightY.Value);
commands[robotId].VelocityTangent = gamepad.LeftY.Value;
commands[robotId].VelocityNormal = gamepad.LeftX.Value;
commands[robotId].AngularVelocity = gamepad.RightX.Value * 10;
commands[robotId].EnableDribbler = true;
output.PostCommands(commands.ToArray());
Thread.Sleep(1000 / 60);
}
}
static void Main(string[] args)
{
RobotControl();
}
}
}