Ziro Logo

Home

Modules UDP Scripts Unity

Examples

Mobile: IMU Cloud: Alexa Arduino: PIXY Arduino: Sensors

UDP Network Protocol

Ziro Kit uses the UDP protocol to transfer the messages to all of it motor modules. The parent module will broadcast the message sent to it. Please note that messages to the parent module can be sent either via UDP or TCP protocol. But we highly recommend to use the UDP protocol as it will broadcast the message to the entire network as compared to the TCP protocol which will send the message to Module-xxx-00 only. The Module-xxx-00 will then broadcast the message to the entire network.

To make your app talk to Ziro Robotics Kit using the UDP protocol, we have a UDP Client script that takes care of all the backend handling for sending UDP packets to the Ziro Motor module. Once the message packet is create it is as simple calling the gameObject.GetComponent ().SendValue (mssg); function with the message (mssg) in it.

The Motor modules understand commands in pType JSON string. The UDP protocol is used to broadcast this pType message to the motor modules in the entire kit.

Message Packets

The structure of a typical pType is as follows:

 {"pType":7,"m_"T":[20,30,60,70,40,80,0],"m_M":[1,2,0,0,0,0,0]};  
To control the motor movements we use the pType:7. This type is followed by m_T and m_M. The structure of this pType corresponds to the chronological order of the module colors in the kit - VIBGYO. For example:
m_T:[Vt,It,Bt,Gt,Yt,Ot]
      Vt: Target value for Violet colored module.
      It: Target value for Indigo colored module.
      Bt: Target value for Blue colored module.
      Gt: Target value for Green colored module.
      Yt: Target value for Yellow colored module.
      Ot: Target value for Orange colored module.
  
m_M:[Vm,Im,Bm,Gm,Ym,Om]
      Vm: Mode value for Violet colored module.
      Im: Mode value for Indigo colored module.
      Bm: Mode value for Blue colored module.
      Gm: Mode value for Green colored module.
      Ym: Mode value for Yellow colored module.
      Om: Mode value for Orange colored module.
  
For modes refer to Modules Section. For example if we have the following message -
 {pType:7,m_T:[20,30,60,70,40,80,0],m_M:[1,2,0,0,0,0,0]}; 
means that the Violet Module is in Clockwise rotation (mode 1) with a rpm value of 20% and Indigo Module is in Anti-clockwise rotation (mode 2) with rpm of 30%. Rest of the modules in the kit - Blue, Green, Yellow and Orange are of coast mode (mode 0). So the modules will not move even though the target values are numerically defined.

For example you can create the packet for sending the message using the UDPClient.cs. Following is an example of the application code that can be written -

    

      private int m_T = 0;
      public int flag = 0;

      private string s_T = "[0,0,0,0,0,0,0]";
      private string s_M = "[0,0,0,0,0,0,0]";

      if (flag == 0)
      {
          s_M = "[2,1,0,0,0,0,0]";
          m_T = 30;
      }

      else if (flag == 1)
      {
          s_M = "[2,1,0,0,0,0,0]";
          m_T = 10;
      }

       s_T = m_T.ToString() + "," + m_T.ToString() + ",0,0,0,0,0";
       string mssg = "{\"pType\":7,\"m_T\":[" + s_T + "],\"m_M\":" + s_M + "}";
       gameObject.GetComponent ().SendValue (mssg);