Object File Format

From CajunBot Wiki

(Redirected from Object files)
Jump to: navigation, search


A custom object file can be supplied for simulation. By default, the simulator needs an object file for the bot, but optional objects can be simulated. In two broad categories, these are static simulated objects, and dynamic simulated objects. The bot and software will interact with these objects much the same as it would interact with similar objects in the real world.

Contents

[edit] Version 2

The new object file format is XML-based to improve readability and also so that a GUI application to manipulate the file could be developed. Cbtraffic_editor can be used to create and edit the new object file format.

An example of the default object file: Objects.xml

<?xml version="1.0" encoding="UTF-8"?>
<object_file>
  <name>Default</name>
  <object type="autonomous" shape="box">
    <!-- type="autonomous" | "dynamic" | "static" -->
    <!-- shape="box" | "sphere" | "cylinder" | "wheel" -->
    <name>CajunBot</name>
    <start_position segment="1" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="1.7" y="3.68" z="2.16"/>
    <wheels type="1" radius="0.38" width="0.20"/><!-- skid=0, conventional=1 -->
    <steering throttle_rate="2" lever_rate="0.5"/>
    <sensor conf="onboard/scan_gp_driver_0.conf" description=""/>
    <sensor conf="onboard/scan_gp_driver_2.conf" description=""/>
  </object>
 
  <object type="dynamic" shape="box">
    <name>Traffic</name>
    <start_position segment="3" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="2" y="4" z="1.5"/>
    <initial_pause>0</initial_pause>
    <goal speed="2" pause="0" segment="3" lane="1" waypoint="2"/>
    <goal speed="3" pause="0" segment="3" lane="1"/>
  </object>
 
  <object type="static" shape="box">
    <name>Box</name>
    <start_position segment="2" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="1.2" y="1.4" z="1.2"/>
  </object>
</object_file>

[edit] Format details

  • The document type should be that of object_file.
  • The document should have a name node, which is usually set to the filename of the object file.
  • The document should have one or more object nodes, which constitute all of the object types that the simulator knows how to deal with.

[edit] Object nodes

There should always be at minimum at least one autonomous object for the simulator to operate properly. Dynamic objects, static object, and mesh objects may or may not be specified, and don't usually have a limit. Typically there is only one autonomous object specified.

[edit] Autonomous objects

Autonomous object nodes have the following attributes:

  • type="autonomous"
  • shape="box"

Autonomous object nodes have the following child nodes:

  • name
    • Usually set to CajunBot
    • No strict guidelines.
  • start_position
    • A specific waypoint. Has the attributes of segment, lane, and waypoint.
  • position_offset
    • Specified in meters with the attributes of x, y, and z.
  • orientation_offset
    • Specified in degrees with the attributes of x, y, and z.
  • size
    • Specified in meters with the attributes of x, y, and z.
  • wheels, with the following attributes:
    • type (usually set to '1')
    • radius (usually set to 0.38)
    • width (usually set to 0.20)
  • steering, with the following attributes:
    • throttle_rate (usually set to 2)
    • lever_rate (usually est to 0.5)
  • Zero or more of "sensor"
    • Each "sensor" has the attribute conf specifying where the configuration file is located. For example "onboard/scan_gp_driver_0.conf". The simulator knows to check $CBCONF/$CBBOTNAME/onboard/scan_gp_driver_0.conf.
[edit] Autonomous object example
  <object type="autonomous" shape="box">
    <name>CajunBot</name>
    <start_position segment="1" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="1.7" y="3.68" z="2.16"/>
    <wheels type="1" radius="0.38" width="0.20"/>
    <steering throttle_rate="2" lever_rate="0.5"/>
    <sensor conf="onboard/scan_gp_driver_0.conf"/>
    <sensor conf="onboard/scan_gp_driver_2.conf"/>
  </object>
[edit] Dynamic objects

Dynamic object nodes have the following attributes:

  • type="dynamic"
  • shape="box"

Dynamic object nodes have the following child nodes:

  • name
    • Usually set to "Traffic Vehicle" or something else.
    • No strict guidelines.
  • start_position
    • A specific waypoint. Has the attributes of segment, lane, and waypoint.
  • position_offset
    • Specified in meters with the attributes of x, y, and z.
  • orientation_offset
    • Specified in degrees with the attributes of x, y, and z.
  • size
    • Specified in meters with the attributes of x, y, and z.
  • initial_pause
    • This is a floating-point value >= 0.0, specifying how long the vehicle should pause before following the first goal.
  • Zero or more of "goal". Each goal has the following attributes:
    • speed, specified in meters per second.
    • pause, specified in floating-seconds, greater than 0. This is the amount of time the vehicle should wait before moving to the next waypoint.
    • segment, the RNDF segment that the dynamic object should move toward.
    • lane, the RNDF lane that the dynamic object should move toward.
    • waypoint (optional).
      • If specified, the RNDF waypoint that the dynamic object should move toward.
      • If not specified, the dynamic object will add goals from the current waypoint to the end of the segment and lane, if it is on the same lane and segment. Otherwise it will add every waypoint as goals. The speed and pause will be carried through as applying to each sub-goal.
[edit] Dynamic object example
  <object type="dynamic" shape="box">
    <name>Traffic Vehicle</name>
    <start_position segment="1" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="2.0" y="4.0" z="1.5"/>
    <initial_pause>0</initial_pause>
    <goal speed="4.470400" pause="0.000000" segment="1" lane="1" waypoint="2"/>
    <goal speed="4.470400" pause="0.000000" segment="1" lane="1"/>
  </object>
[edit] Static objects

Static object nodes have the following attributes:

  • type="static"
  • shape="box"

Static object nodes have the following child nodes:

  • name
    • Usually set to "Static Obstacle" or something else.
    • No strict guidelines
  • start_position
    • A specific waypoint. Has the attributes of segment, lane, and waypoint.
  • position_offset
    • Specified in meters with the attributes of x, y, and z.
  • orientation_offset
    • Specified in degrees with the attributes of x, y, and z.
  • size
    • Specified in meters with the attributes of x, y, and z.
[edit] Static object example
  <object type="static" shape="box">
    <name>Static Obstacle</name>
    <start_position segment="1" lane="1" waypoint="1"/>
    <position_offset x="0" y="0" z="0"/>
    <orientation_offset x="0" y="0" z="0"/>
    <size x="1.2" y="1.2" z="1.2"/>
  </object>
[edit] Mesh objects

Static object nodes have the following attributes:

  • type="mesh"

Static object nodes have the following child nodes:

  • name
    • Usually set to "Mesh" or something else.
    • No strict guidelines.
  • vertices, with an attribute and a text child node. The text child node refers to the relevant filename.
    • path, set to either "full" or "base".
      • full - the text child filename refers to the full path filename.
      • base - the text child filename refers to the base path filename, which will be searched for in the current working directory of the simulator when invoked.
  • indices, with an attribute and a text child node. The text child node refers to the relevant filename.
    • path, set to either "full" or "base".
      • full - the text child filename refers to the full path filename.
      • base - the text child filename refers to the base path filename, which will be searched for in the current working directory of the simulator when invoked.
[edit] Mesh object example
  <object type="mesh">
    <name>Mesh</name>
    <vertices path="base">vertices.txt</vertices>
    <indices path="base">indices.txt</indices>
  </object>

[edit] Version 1

[edit] Sample

A sample object file can be found here: Sample.obj

3 // number of objects
0 // object type: dyn_sim = 0; dyn_no_sim = 1; static = 2
0 // controller: sensor = 0; manual = 1, script = 2, waypoint = 3
1 // object id num: must be unique
0 // shape: box = 0, sphere = 1, cylinder = 2, wheel = 3
1 2 3
0 // pos x
0 // pos y
0 // pos z
1.7 // size x
3.68 // size y
2.16 // size z
0 // orient x
0 // orient y
0 // orient z
1 // wheel type: 0 = skid; conventional = 1;
0.38 // wheel radius
0.20 // wheel width
2 // throttle rate
0.5 // lever rate
2 // number of sensors
0
onboard/scan_gp_driver_0.conf
0
onboard/scan_gp_driver_2.conf
 
2 // object type = static
6 // unique object id
0 // shape = box
4 5 6 // position
0 // xpos
0 // ypos
0 // zpos
1.2 // xsize
1.2 // ysize
1.2 // zsize
0 // xrotation
0 // yrotation
0 // zrotation
 
1 // object type = dyn_no_sim
8 // object is scripted, so this is num of waypoints to follow
5 // speed
0 // pause
1 1 1 // waypoint
5 // speed
0 // pause
1 1 2 // waypoint
5 // speed
0 // pause
1 1 3 // waypoint
5 // speed
0 // pause
1 1 4 // waypoint
5 // speed
0 // pause
1 1 5 // waypoint
5 // speed
0 // pause
1 1 6 // waypoint
5 // speed
0 // pause
1 1 7 // waypoint
5 // speed
0 // pause
1 1 8 // waypoint
7 // unique object id
0 // shape = box
7 8 9 // start position
0 // xpos
0 // ypos
0 // zpos
2 // xsize
4 // ysize
1 // zsize
0 // xrotation
0 // yrotation
0 // zrotation

[edit] Format

The format the simulator expects to see in the object file:

# of objects, int
object type: dyn_sim = 0; dyn_no_sim = 1; static = 2
IF object_type == MESH
    vertices-file
    indices-file
    segment_id lane_id wp_id // this is RNDF waypoint, to give relative pos, put
    continue to next object
END IF
IF object_type != STATIC
  controller: sensor = 0; manual = 1, script = 2, waypoint = 3
END IF
IF controller = 2(script) OR = 3(waypoint) then
   # of waypoints for script to follow
   FOR EACH waypoint have
      IF controller = 2(script) then
        {
	   speed (roughly m/s)
           pause time (s)
	   distance to travel
           angle in degress, global and not local(not relative)
        }
      ELSE IF controller = 3(waypoint) then
        {
    	   speed (roughly m/s)
           pause time (s)
           waypoint id
       }
      END IF
   END FOR
END IF
object id num: must be unique 
shape: box = 0, sphere = 1, cylinder = 2, wheel = 3, mesh = 4
segment_id lane_id wp_id // this is RNDF waypoint, to give relative pos, put
// zeros to disable this feature(and use pos 0, 0, 0) + offsets below
pos x // all pos, size and orientation are floating point
pos y
pos z
size x
size y
size z
orientation x
orientation y
orientation z
IF object_type = 0 (dyn_sim) THEN
   wheel type, int; 0 = skid, 1 = conventional
   wheel radius, float
   wheel width, float
   throttle rate, float
   lever rate, float
   # of sensors, int
   IF # of sensors > 0 THEN FOR EACH sensor have
     sensor type
     sensor conf file
   END IF
ENDIF

That's the end of the first object, can have as many objects as you want appended to list.

[edit] See also

Personal tools