/// <summary> /// Send a given DriveCommand to ROCKS. /// </summary> /// <param name="driveCommand">The DriveCommand to be executed.</param> /// <returns>bool - If DriveCommand was successfully sent.</returns> public static void SendDriveCommand(DriveCommand driveCommand) { // Form payload for BCL drive command from specified DriveCommand byte[] bclPayload = DriveCommandToBclPayload(driveCommand); // Send opcode, payload to AscentPacketHandler to send drive packet to ROCKS AscentPacketHandler.SendPayloadToROCKS(OPCODE_ALL_WHEEL_SPEED, bclPayload, AscentPacketHandler.ROCKS_AI_SERVICE_ID); // For debugging Console.WriteLine("left: " + (sbyte)driveCommand.Left + " | right: " + (sbyte)driveCommand.Right); }
public static void SendDebugAIPacket(Status status, string debugMessage) { List <byte> payload = new List <byte>(); // if debug message is too long, truncate if (debugMessage.Length >= 150) { debugMessage = debugMessage.Substring(0, 150); } // convert everything to bytes payload.Add((byte)status); payload.AddRange(Encoding.ASCII.GetBytes(debugMessage)); payload.AddRange(new byte[151 - payload.Count]); // zero extend AscentPacketHandler.SendPayloadToROCKS(AscentPacketHandler.OPCODE_DEBUG_AI, payload.ToArray(), AscentPacketHandler.ROCKS_AI_SERVICE_ID); }
public static void SendSimpleAIPacket(Status status, byte[] option = null) { // check whether an additional 8 bytes are specified option = option ?? new byte[8]; // truncate if option is larger than 8 bytes if (option.Length > 8) { option = new byte[8] { option[0], option[1], option[2], option[3], option[4], option[5], option[6], option[7] } } ; List <byte> payload = new List <byte>(new byte[] { (byte)status }); payload.AddRange(option); AscentPacketHandler.SendPayloadToROCKS(AscentPacketHandler.OPCODE_SIMPLE_AI, payload.ToArray(), AscentPacketHandler.ROCKS_AI_SERVICE_ID); }