Lab 4 · The Drive Graph

What you do in this lab

The Action Graph editor: four key nodes on the left, then Throttle, MaxSpeed, Speed, Turn and SteeringAngle, then the Ackermann node and two joint nodes on the right
// The top of the drive graph in the Action Graph editor. Read it from left to right.

In the last lab you drove the car and opened its graph. Now you read that graph, node by node: 27 nodes that turn four keys into six joint commands. Then you change it while the car drives.

Do this: read the cards. Then open the graph on the desktop, find each group of nodes, and do the three experiments.

Nodes, pins and two kinds of wire

An OmniGraph is a program that you can see. A node is one small function. A pin on its left side is an input, a pin on its right side is an output. A wire moves a value from an output to an input.

There are two kinds of wire, and they answer two different questions.

data wireWHAT: it moves a number, for example the speed.
execution wireWHEN: it says "run now". It starts at a white arrow pin.

Our graph has one execution chain: Tick to Odometry to Ackermann to the two joint nodes. Tick fires one time per frame while the simulation plays. A math node (subtract, multiply) has no execution pin: it gives its value when a node downstream asks for it.

The graph is a prim (an item on the stage) at /World/DriveGraph, and each node is a prim below it. So you find the nodes in the Stage panel too.

From keys to a speed and a turn

The left side of the graph has the same four steps two times: one time for the throttle, one time for the turn.

KeyForward KeyReverse KeyLeft KeyRightRead Keyboard State: is the key W, S, A or D down? True or false.
Forward Reverse Left RightTo Double: true becomes 1.0, false becomes 0.0.
ThrottleForward - Reverse: 1, 0 or -1.
TurnLeft - Right: 1 is left, -1 is right.
SpeedThrottle x MaxSpeed (3 m/s).
SteeringAngleTurn x the output of SteerLimit.

Hold W and S together: 1 - 1 = 0, and the car stops. A key gives only 1 or 0, so the graph asks for full speed or none. The Ackermann node makes that smooth (see below).

The steering limit

The lower row of the graph: Tick, Odometry, CarSpeed, SpeedSquared, Floor, GripAngle and SteerLimit, with the constants Tiny, TurnGrip, Zero and MaxSteer below
// The row below: from the speed of the car to the largest steering angle. Move the view with the middle mouse button.

This row is one formula, one node per operation:

limit = TurnGrip / (speed x speed + Tiny)      then held between Zero and MaxSteer
OdometryReads the velocity of the chassis from the physics.
CarSpeedThe length of that velocity: the speed in m/s.
SpeedSquaredspeed x speed.
FloorAdds Tiny (0.01), so the next node does not divide by zero when the car stands.
GripAngleTurnGrip (1.28) divided by that sum.
SteerLimitClamp: not below Zero, not above MaxSteer (0.5 rad).

TurnGrip is the wheelbase (0.32 m) x the sideways acceleration that the steering may ask for (4 m/s^2). The tires hold about 8, so 4 leaves a margin.

up to 1.6 m/s0.50 rad (full lock)
3 m/s0.14 rad
5 m/s0.05 rad

The Ackermann node and the joints

Ackermann gets one speed and one steering angle for the car as a whole. It gives one angle for each front wheel and one turn rate for each of the four wheels. It knows the car from its inputs: wheelbase 0.32 m, track width 0.24 m, wheel radius 0.05 m.

acceleration4 m/s^2: from 0 to 3 m/s in 0.75 s, not in one frame.
steeringAngleVelocity1.5 rad/s: the wheels need time to turn.
maxWheelRotation0.5 rad: no wheel turns more than full lock.

The last two nodes are Articulation Controllers. They write the commands to the joints of the car.

SteerJointsA position command (an angle) to the 2 steering joints.
WheelJointsA velocity command to the 4 wheel joints: 60 rad/s at 3 m/s.

60 rad/s is the speed divided by the wheel radius: 3 / 0.05. The physics does the rest: the motors of the joints turn the wheels, and the tires push the car.

Change the graph while the car drives

The Property panel with the node MaxSpeed selected: a Constant Double Node with the input Value 3.0
// MaxSpeed in the Property panel. Type a new Value and press Enter.

The graph runs each frame, so a new value has an effect on the next frame. You do not stop the simulation.

Do this: three experiments.

  1. Set MaxSpeed to 5. Drive a straight, then a corner. The car is faster and steers less: the limit at 5 m/s is 0.05 rad.
  2. Set TurnGrip to 4. Take a corner at full speed. The car slides: the graph now asks for more grip than the tires have.
  3. Set TurnGrip back to 1.28. Select KeyForward and set its Key from W to I, in the list. Now I is the throttle.

Nothing that you change is saved. Run ./lite.sh drive --graph again and the graph is as before.

Follow the White Rabbit

The graph is made by one call in goatracer_lite/drive.py: a list of nodes, a list of values and a list of wires. Read it on the desktop, next to the editor: less goatracer_lite/drive.py. Each name in the editor is a name in that file.

Play

  1. Open the Desktop Press Start a desktop and wait for the screen. It opens in a new tab; keep this one for the steps.
  2. In the terminal named GoatRacerLite, type:
    ./lite.sh drive --graph
    The car shows, and the graph opens below it with a name on each node.
  3. Find the four groups: the keys on the left, Speed and SteeringAngle in the middle, Ackermann and the joints on the right. Move the view down with the middle mouse button: the steering limit is the row below. The mouse wheel is the zoom.
  4. Click one time in the picture of the car and drive with W S A D. The graph runs while you drive.
  5. Click the node MaxSpeed. The Property panel, on the right, shows its Value. Type 5 and press Enter. Click in the picture of the car again, and drive.
  6. Do the same with TurnGrip (4, then 1.28 again), and with the Key of KeyForward.
  7. Press Stop on the Desktop page when you are done. The minutes stop there.

// No names on the nodes? Turn the mouse wheel to zoom in. No keys? Click in the picture of the car again.

Code

// The nodes of the graph, from goatracer_lite/drive.py. Each pair is a name and a node type. The name is what the editor shows.

("Tick", "omni.graph.action.OnPlaybackTick"),
("KeyForward", read_key), ("KeyReverse", read_key), ("KeyLeft", read_key), ("KeyRight", read_key),
("Forward", "omni.graph.nodes.ToDouble"), ("Reverse", "omni.graph.nodes.ToDouble"),
("Left", "omni.graph.nodes.ToDouble"), ("Right", "omni.graph.nodes.ToDouble"),
("Throttle", "omni.graph.nodes.Subtract"), ("Turn", "omni.graph.nodes.Subtract"),
("MaxSpeed", "omni.graph.nodes.ConstantDouble"), ("MaxSteer", "omni.graph.nodes.ConstantDouble"),
("Speed", "omni.graph.nodes.Multiply"), ("SteeringAngle", "omni.graph.nodes.Multiply"),

("Odometry", "isaacsim.core.nodes.IsaacComputeOdometry"), ("CarSpeed", "omni.graph.nodes.Magnitude"),
("SpeedSquared", "omni.graph.nodes.Multiply"), ("Floor", "omni.graph.nodes.Add"),
("Tiny", "omni.graph.nodes.ConstantDouble"), ("TurnGrip", "omni.graph.nodes.ConstantDouble"),
("GripAngle", "omni.graph.nodes.Divide"), ("Zero", "omni.graph.nodes.ConstantDouble"),
("SteerLimit", "omni.graph.nodes.Clamp"),

("Ackermann", "isaacsim.robot.wheeled_robots.AckermannController"),
("SteerJoints", "isaacsim.core.nodes.IsaacArticulationController"),
("WheelJoints", "isaacsim.core.nodes.IsaacArticulationController"),

// Some of the values. The file sets them one time, when it makes the graph.

("KeyForward.inputs:key", "W"), ("KeyReverse.inputs:key", "S"),
("KeyLeft.inputs:key", "A"), ("KeyRight.inputs:key", "D"),
("MaxSpeed.inputs:value", float(speed)), ("MaxSteer.inputs:value", STEER_MAX),
("Tiny.inputs:value", 0.01), ("Zero.inputs:value", 0.0),
("TurnGrip.inputs:value", WHEELBASE * TURN_ACCEL),     # angle limit = wheelbase * a / v^2
("Ackermann.inputs:acceleration", 4.0),               # m/s^2: the launch ramp

Do this: count the node types. The graph has 27 nodes and 13 types. Which type has the most nodes?