/// <summary> /// Sends the given command to the Jumping Sumo. Non-PCMD commands are sent immediately /// while PCMD commands are sent at the next cycle(see run). cmd is the payload and the /// method creates a frame by prepending a header /// </summary> /// <param name="cmd"></param> public void Send(byte[] cmd) { if (isConnected) { if (cmd != null) { byte[] frame = this._update_seq(SumoCommandsCustom._pack_frame(cmd)); if (SumoCommandsCustom._is_pcmd(frame)) { this.cmd = frame; } else { sumoSocket.Send(frame, frame.Length, SumoRemote); } } } }
private void SumoSend() { try { LOGGER.GetInstance.Info("[SumoSender] Thread Started"); while (isConnected) { sumoSocket.Send(this.cmd, this.cmd.Length, SumoRemote); this.cmd = SumoCommandsCustom._pack_frame(SumoCommandsCustom.Move_cmd(0, 0)); Thread.Sleep(40); } } catch (Exception e) { LOGGER.GetInstance.Error(e.Message); } LOGGER.GetInstance.Info("[SumoSender] Thread Stopped"); }
/// <summary> /// Apply the given speed and turn to the Jumping Sumo /// :param speed: [-100, 100] /// :param turn: [-100, 100] /// :return: /// </summary> /// <param name="speed"></param> /// <param name="turn"></param> public void SendMove(sbyte speed, sbyte turn) { this.sender.Send(SumoCommandsCustom.Move_cmd(speed, turn)); }