Control

PID Controller

To translate our waypoints to throttle, steering and brake control, we're using a Proportional Integral Derivative (PID) controller that is able to adjust the throttle, steering and breaking according to the car position and speed by comparing it to the desired waypoints. The code can be found in operator/pid_control_op.py.

For more information on pid, go on our pid detail page

Control

The actual command being applied to the car is controlled within the oasis_agent.

Fully looped graph

We have now all our starter kit node. They will look like this:

# graphs/oasis/oasis_agent.yaml

nodes:
  - id: oasis_agent
    custom:
      inputs:
        control: pid_control_op/control
        tick: dora/timer/millis/400
      outputs:
        - position
        - speed
        - image
        - objective_waypoints
        - lidar_pc
        - opendrive
      source: shell
      # args: >
        # python3 $SIMULATE --output 
        # --oasJson --criteriaConfig $CRITERIA
        # --openscenario $XOSC
        # --agent $TEAM_AGENT
        # --agentConfig $TEAM_AGENT_CONF
        # --destination $DESTINATION
      #
      # or for Carla Standalone:
      #
      args: python3 ../../carla/carla_source_node.py

  - id: carla_gps_op
    operator:
      python: ../../carla/carla_gps_op.py
      outputs:
        - gps_waypoints
      inputs:
        opendrive: oasis_agent/opendrive
        objective_waypoints: oasis_agent/objective_waypoints
        position: oasis_agent/position

  - id: yolov5
    operator: 
      outputs:
        - bbox
      inputs:
        image: oasis_agent/image
      python: ../../operators/yolov5_op.py
    env:
      # CUDA_VISIBLE_DEVICES: ""
      PYTORCH_DEVICE: cuda

  - id: obstacle_location_op
    operator: 
      outputs:
        - obstacles
      inputs:
        lidar_pc: oasis_agent/lidar_pc
        obstacles_bbox: yolov5/bbox
        position: oasis_agent/position
      python: ../../operators/obstacle_location_op.py

  - id: fot_op
    operator:
      python: ../../operators/fot_op.py
      outputs:
        - waypoints
      inputs:
        position: oasis_agent/position
        speed: oasis_agent/speed
        obstacles: obstacle_location_op/obstacles
        gps_waypoints: carla_gps_op/gps_waypoints
 
  - id: pid_control_op
    operator:
      python: ../../operators/pid_control_op.py
      outputs:
        - control
      inputs:
        position: oasis_agent/position
        speed: oasis_agent/speed
        waypoints: fot_op/waypoints

  - id: plot
    operator:
      python: ../../operators/plot.py
      inputs:
        image: oasis_agent/image
        obstacles_bbox: yolov5/bbox
        obstacles: obstacle_location_op/obstacles
        gps_waypoints: carla_gps_op/gps_waypoints
        position: oasis_agent/position
        waypoints: fot_op/waypoints
        control: pid_control_op/control

To run a running car example:

dora up
dora start graphs/oasis/oasis_agent.yaml --attach

😎 We now have a working autonomous car!

You might have noticed that improvement can be done in many place.

In case you need inspiration, we advise you check:

  • operators/yolop_op.py that enables you to detect lanes. It can be passed to the obstacle location to get the 3D position of the lanes. Those 3D position of lanes can then be passed to fot to plan by taking into account lanes on the floor.
  • operators/strong_sort.py that enables tracking 2D bounding box through times. This can be useul if you want to avoid moving vehicles.
  • opertators/traffic_sign.py that is self-trained traffic light detection based on yolov7 and tt100k. THis can be useful to avoid traffic light.