Accessing Peripherals - Controlling the Car

Instructions

In this activity, you must control a car to move it from a parking lot to the entrance of the Test Track (shown in the picture below) in, at most, 180 seconds. The car is an external device connected to the RISC-V processor and can be controlled by syscalls or MMIO.

car

Figure 7.1.1: Car Simulation

  • In this exercise, you must use only MMIO to control the car. The MMIO specifications for the peripherals of the simulator can be seen in the ALE Peripheral MMIO Manual.
    • You only need to use MMIO to control the steering wheel, engine, brakes and get coordinates.
    • The entrance to the Test Track is placed at:
      • x: 73, y: 1, z: -19
    • The base address is shown at the table "Memory Map" (see example below)
  • The car will be considered to have reached its destination when it reaches a point inside a radius of 15 meters from the Test Track entrance. Your code must call the exit syscall to finalize the execution.

Infrastructure

In order to use the car, first you must enable the device 'Self-Driving Car' on the RISC-V simulator. This can be done on the tab 'Hardware' and selecting the device ‘Self-Driving Car’ as shown in the picture below.

After adding the device, its base address will be listed on the table:

peripheral_table

Figure 7.1.2: Memory Map Table

The car can be accessed through 'Self-driving car', on the left bar, as shown in the picture below. The car icon can take a while to appear for the first time.

car menu

Figure 7.1.3: Car Menu Tab

Note that, after adding the device, the car will be placed in an arbitrary position. Use the Assistant to place the car inside the parking lot.

In addition to that, you can test moving the car manually using the arrow keys or WASD. To do so, enable the option ‘Enable debug controls’ on the simulator, as demonstrated below.

car debug

Figure 7.1.4: Debug Controls

Notes and Tips

  • Check the ALE Peripheral MMIO Manual for information about the Self Driving Car peripheral.
  • The starting point and destination are fixed. You have to use the assistant to place the car at the starting point (there is a button on the assistant that can be used for that).
  • The steering wheel direction values range from -127 to 127, negative values steer to the left and positive values to the right.
  • For debugging purposes, you can control the car when the test fails, using the keys WASD or arrow keys, with the option ‘‘Enable debug controls’’ enabled. However, this option can't be enabled while your code is running on the simulator.
  • You can test your code using the simulator's assistant from this link.