Reading sensors using XML

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable (Wikipedia). Roomba Wi-fi Remote has an externally accessible file that allows developers the ability to perform a reading of the various sensors of the robot through an interpreter / standard XML parser.

Different tags or fields are included in the XML file. Each tag defines a sensor of the iRobot Roomba. The structure defines the request commands [142][0] were all sensors are read. These files are named roomba.xml and rwr.xml that can be accessed from the URL http:// Roomba_Wi-fi_Remote_IP/roomba.xml and http:// Roomba_Wi-fi_Remote_IP/rwr.xml

Remember that Roomba Wi-fi Remote requires of user and password. For this reason leave this two fields in blank when configuring the device with XML. Otherwise the communication will be very slow.

Given that the file is updated at the same time of execution, only two simultaneous connections to roomba.xml and/or rwr.xml are allowed. This also occurs when accessing through the web interface of the Roomba Wi-fi Remote.

Finally, another important information to take into account: in order to balance the embedded workload and create an efficient TCP/IP connection, when a connection to 9001 port is detected (Transparent Mode or Gateway), the refresh process of these files is interrupted (explained in Transparent Mode Section).

roomba.xml

roomba.xml file is a read-only file and it is only updated with the value read from the robot sensors. Sensors value is updated every 500ms and it does not depends on the accesses or reads to the file (values are updated periodically). Note this is an important data, see Angle and Distance dedicated section on the SCI iRobot Roomba manual.

The fix part of the XML file structure is as shown below:

<response>
  <r0>
    <name>'Bumps Wheeldrops'</name>
    <value>VALOR</value>
  </r0>
  <r1>
    <name>'Wall'</name>
    <value>VALOR</value>
  </r1>
  <r2>
    <name>'Cliff Left'</name>
    <value>VALOR</value>
  </r2>
  <r3>
    <name>'Cliff Front Left'</name>
    <value>VALOR</value>
  </r3>
  <r4>
    <name>'Cliff Front Right'</name>
    <value>VALOR</value>
  </r4>
  <r5>
    <name>'Cliff Right'</name>
    <value>VALOR</value>
  </r5>
  <r6>
    <name>'Virtual Wall'</name>
    <value>VALOR</value>
  </r6>
  <r7>
    <name>'Motor Overcurrents'</name>
    <value>VALOR</value>
  </r7>
  <r8>
    <name>'Dirt Detector - Left'</name>
    <value>VALOR</value>
  </r8>
  <r9>
    <name>'Dirt Detector - Right'</name>
    <value>VALOR</value>
  </r9>
  <r10>
    <name>'Remote Opcode'</name>
    <value>VALOR</value>
  </r10>
  <r11>
    <name>'Buttons'</name>
    <value>VALOR</value>
  </r11>
  <r12>
    <name>'Distance'</name>
    <value>VALOR</value>
  </r12>
  <r13>
    <name>'Angle'</name>
    <value>VALOR</value>
  </r13>
  <r14>
    <name>'Charging State'</name>
    <value>VALOR</value>
  </r14>
  <r15>
    <name>'Voltage'</name>
    <value>VALOR</value>
  </r15>
  <r16>
    <name>'Current'</name>
    <value>VALOR</value>
  </r16>
  <r17>
    <name>'Temperature'</name>
    <value>VALOR</value>
  </r17>
  <r18>
    <name>'Charge'</name>
    <value>VALOR</value>
  </r18>
  <r19>
    <name>'Capacity'</name>
    <value>VALOR</value>
  </r19>
</response>

The main field for each sensor is called <rX>, where X represents the sensor that is being monitored. Every tag <rX> specifies the name of the sensor by to fields: <name> which contains the name given by the vendor, and <value>, which contains the sensor value. This way the user can obtain the sensor information from the XML file and doesn’t need to store all sensors hardcoded.

All <rX> sensors are listed inside a tag called <response>: Roomba Wi-fi Remote translate the answer to a block sensors frame that allows reading all sensors at a time.

rwr.xml

This file contains the sensors values read through an information request to the iRobot Roomba (same information that can be got from the file explained before).

The difference is that in this case the information contained in <rX> tags disappear (<name> and <value> fields are not used). In order to clarify the differences between the two files, find below an example of rwr.xml file (compare it to a Roomba.xml file).

<response>
  <r0>VALOR</r0>
  <r1>VALOR</r1>
  <r2>VALOR</r2>
  <r3>VALOR</r3>
  <r4>VALOR</r4>
  <r5>VALOR</r5>
  <r6>VALOR</r6>
  <r7>VALOR</r7>
  <r8>VALOR</r8>
  <r9>VALOR</r9>
  <r10>VALOR</r10>
  <r11>VALOR</r11>
  <r12>VALOR</r12>
  <r13>VALOR</r13>
  <r14>VALOR</r14>
  <r15>VALOR</r15>
  <r16>VALOR</r16>
  <r17>VALOR</r17>
  <r18>VALOR</r18>
  <r19>VALOR</r19>
</response>
Tagged with: , , , ,
Posted in Developers, RoombaWi-fi Remote v2