SCANeR QUICK STARTS

Resources to discover SCANeR

How to evaluate and validate an ADAS system

This guide explains how to interface your ADAS system with SCANeR studio.

This tutorial requires the Foundation and AD/ADAS packs. If you don’t have them already, get your Trial version of SCANeR and follow this walk-through.

The Samples Pack includes example ADAS already interfaced to SCANeR:

  • SAMPLE_ADAS_AEB: I recommend this one for an easy to understand example to refer to along this guide.
  • SAMPLE_ADAS_LKA_ACC: A more comprehensive example with driver inputs and dashboard.
  • SAMPLE_LATERAL_CTRL &* SAMPLE_LONGI_CTRL: Focus on each available level of control: speed, acceleration, pedals, steering wheel.

Principle

SCANeR studio hosts the vehicle model, sensors and the interfaces that allow the connection to your ADAS model.

The SCANeR API is the interface. It enables the reading of the vehicle status, driver inputs and sensors outputs.

Interface Principle

For the current tutorial, we are going to focus on a simple Automated Emergency Braking (AEB) situation. The brakes should be activated when a pedetrian is detected too close in front of the EGO vehicle.

We will need

Before starting, create a dedicated workspace called TUTO_ADAS for instance.

Step 1. Sensor

Functional sensor model

In this step, we will use the radar sensor functional model (L1).

Note: SCANeR functional models are part of the AD/ADAS Pack. They use simulation logical content and 3D world models to determine a sensor’s outputs. These are perfect models returning perfect targets’ list. You can add noise to simulate signal perturbation. SCANeR functional models are made for you if you want to focus on the ADAS system itself or effortlessly simulate any of the 6 Levels of Vehicle Autonomy.

If you want to focus on sensor processing, check out our Physics Based Sensors Pack.

SCANeR comes with a set of example sensor models to help you to begin. To view and edit existing sensor models go to RESOURCES panel > Sensors tab.

We will use aLongRangeRadarSensor as a template for our sensor model.

This dialog enables the control of any sensor’s parameters as a beam (e.g. quantity, shape, range, etc.). Let’s add a Pedestrian mobile obstacle to the detection capabilities.

Your LRRS1 radar model is ready and available from SCANeR resources :thumbsup:

Sensor Module

During the simulation, the radar sensor model is managed by the module SENSORS.

Step 3. Scenario

In this step, we will design our experiment by defining the environment (the proving ground), the actors, the sensors, the story and the KPI/Metrics we would like to get for post-analysis.

We will use default models included in SCANeR:

  1. Create a new scenario.
    Go to menu FILE> New Scenario, select Community environment and click on OK
  2. Add an Ego vehicle.
    Find RESOURCES panel > Vehicles tab > Cars (Callas) > SmallFamilyCar and drag and drop it onto a straight road in the main view.
  3. Add a pedestrian Find RESOURCES panel > Pedestrians tab > Kid_Boy_02 and drag and drop it onto the sidewalk, about 50 meters ahead of the Ego vehicle.

Ego’s driver

By default, CALLAS vehicles are driven by a Human Driver (using the keyboard, game controller or simulator). In order to add some repeatability, we will change to Virtual Driver.

Note: A Virtual Driver acts similar to a Human Driver by using the vehicles inputs (pedals, steering wheel, …), but they are automated. The Virtual Driver can be asked to follow specific trajectory and speed. It strictly follows the inputs it is given, and nothing else.

An Autonomous Driver would follow traffic rules by simulating realistic human driving behavior. It would stop upon seeing the pedestrian on the road, and our ADAS wouldn’t be triggered. Although it is possible to configure this human driving emulation at a high level (to disable the attention to pedestrian, for instance), it does not offer as much control as a Virtual Driver. So for this example we prefer Virtual Driver.

We want to force our Virtual Driver to follow a straight line at a speed of 50 kmph.

  Time(s) Speed (km/h) Gearbox ratio
1 0 50 1
2 60 50 1

Ego’s sensor configuration

Earlier we defined a sensor model “LRRS1”. We can now attach it to the car, at a specified position on the front bumper.

Pedestrian’s activation

The pedestrian should not move until the Ego vehicle within 20 meters. In order to force the pedestrian to stay put, we should deactivate it.

Pedestrian crossing

The pedestrian should start moving, and cross the road when the Ego vehicle gets closer than 20 meters. A combination of a Trigger and Scripting will allow us to do that.

Start by setting up the trigger.

Now we can add the scripting rule: IF Ego drives on Trigger THEN activate Pedestrian AND Pedestrian crosses the road.

Well done, the scenario is ready !

If you want to try the scenario at this stage, launch the MODELHANDLER (for Ego), ACQUISITION (for Virtual Driver), PEDESTRIANTRAFFIC (for the Pedestrian), SCENARIO (for the script) and TRAFFIC (for the Trigger) modules. Then start the simulation. You will see that the car drives strictly at 50 kmph. When it reaches the Trigger, the Pedestrian crosses the road. Eventually, the Ego vehicle collides with the pedestrian.

Now by connecting the AEB, we can avoid the collision.

Step 2. ADAS model

To implement the ADAS model, we will develop a SCANeR custom module. Such module uses the SCANeR API to read from and write to the SCANeR simulation data buses: Network and Shared Memory.

Note: The current demostration is using C++, but the same can be done with any other programming interface like Simulink, Python, etc…

C++ project

SCANeR API projects should be compiled with Microsoft Visual Studio C++ 2019

You can initialize the C++ project with the following SDK package.

Note: For ease of use, we recommend to clone the SCANeR API sample projects that can be found in %STUDIO_PATH%/SCANeRstudio_2021/APIs/samples/complete.sln with Visual Studio 2019. For the current purpose, %STUDIO_PATH%/SCANeRstudio_2021/APIs/samples/ScanerAPI/SampleCom/Radar/scanerAPISampleRadar.vcxproj is a good candidate to duplicate and start modifying.

Note: For demonstration purpose, we will include the simulation data interface and the simple AEB algorithm in the same project code. But for a larger project, we recommend dividing the project in two parts: the interface (SCANeR API) and the algorithm.

Declare interfaces

The first step is to declare the interface handles to SCANeR simulation data. This is to be done once at the launch of the custom module.

The ADAS model takes inputs from and outputs to SCANeR:

// read access to radar and ExportChannel
DataInterface* radar_300000 = Com_declareInputData(NETWORK_ISENSOR_SENSORMOVABLETARGETS, 300000); //connect to "ISensor/SensorMovableTargets" with radar ID 300000 (default number for the first
// write access to Shared Memory for longitudinal control
DataInterface* CabToModelCorrective_0	= Com_declareOutputData(SHM_MODELCABIN_CABTOMODELCORRECTIVE, 0); //connect to "ModelCabin/CabToModelCorrective" of vehicle ID 0 (Ego)

**Note: ** The manual documents Network.html and Shared Memory found under the HELP menu of SCANeR lists all the available messages. Use it to find the name of the message that you need.

Network and Shared Memory act and are use in the same way. But Shared Memory messages are only exchanged on the same computer, when Network messages can be exchanged on any computer of the simulator’s network.

Read & write

Now the values can actually be read from and written to SCANeR simulation buses using the handles. This is typically done in a main loop.

short targetsCount = Com_getShortData(radar_300000, "targetsArrayCount"); //read member "targetsArrayCount" of "ISensor/SensorMovableTargets"
if (targetsCount > 0)
{
  char distanceToCollisionTmp[50];
  sprintf_s(distanceToCollisionTmp, "targetsArray[%d]/distanceToCollision", Com_getShortData(radar_300000, "nearestTarget"));
  distanceToCollision = Com_getFloatData(radar_300000, distanceToCollisionTmp);
}

Frame

//scaner project includes
#include "scanerAPI/scanerAPI_DLL_C.h"
#include "scanerAPI/ScanerAPImessagesNetwork.h"
#include "scanerAPI/ScanerAPImessagesShm.h"

int main(int argc, char* argv[])
{
  Process_Init(argc, argv);
  APIProcessState status = PS_DAEMON;

  /* INITIALIZE HERE */

  while (status != PS_DEAD) // main loop
  {
    Process_Wait(); // syncrhonization
    Process_Run(); // step

    status = Process_GetState();
    
    if (status == PS_RUNNING) // simulation is running
    {
      /* RUN HERE */
    }
  }
  Process_Close();
}

Conclusion

Congratulations on connecting your ADAS model.

Here are some suggestions to customize and enhance the sample:

:arrow_right: SAMPLE_ADAS_AEB