Accessing Sensor Data


I’ve been working on the development of a NMPC Controller for automated vehicles. At the moment, we are working on the Path Tracking. I’ve been trying to access data from sensors but the output I get is a constant zero. The sensors (mounted at the CoG coordinates) that I’ve been trying to log are:

  • Road Sensor, to get Distance to the Path/Route (in the images below, there’s a sensor called “test” that I created for that intent).
  • Global Navigation, to get the X,Y coordinates of the Center of Gravity (I’m using an already existing sensor that we have).

I’ve been trying to get such data from the CarMaker Sensor library on Simulink.


Do you know what am I doing wrong and how can I effectively get such data from the sensors?

Thanks in advanced!


I think in “Along vehicle” mode, the road sensor does not return the deviation at all. This is why you see it as a constant 0. This is what I found in the Reference Manual regarding this issue:


Hi Bogomil,

Thanks for your reply :slight_smile:

I understand what you are pointing out. However, it should not be that difficult to get information from a sensor that is located in the CoG, right? :sweat_smile: I’m facing the same issue with the Gloabl Navigation Sensor so I think they might be somewhat related to each other.

Thanks anyways,


CarMaker should already have a built-in road sensor even without adding one.
I think reading the Vhcl.tRoad quantity in Simulink may be of great help here:

This will give you the deviation of the centre of mass of the vehicle to the route centreline.

For what it does, the Global Navigation Sensor is actually quite complex. It simulates a real satnav sensor with multiple sources of noise, but it requires a fair amount of work to setup. You need your scenario to have realistic GPS coordinates built into the definition of its origin. You also need historic GPS data from the actual date and time of the simulation that you are running. The data is open-source and available from the NASA repositories, but usually doing all this is an overkill for what most CarMaker customers want to achieve. If you simply want to know where the car is at any point in time, that is available as UAQs in CarMaker without using a Nav sensor.


Hello Bogomil,

Thanks once again for your reply. The reason why I was not using Vhcl.tRoad is because I couldn’t find on the Reference Manual that such output is especifically from the CoG (and not from any other point of the car).

Do you know if such distance to path is from the CoG?

Regarding the GPS, as far as I’ve seen on the Reference Manual, the UAQ that I can use to get the location of the vehicle considers the hitch point (FR1) and not the CoG. That’s why I thought in using the GPS sensor.

Do you now the UAQ that considers the CoG to localize the vehicle?

Thanks once again for your time,

Regarding tPath and sPath, I will have to verify which point they reference. The reason i suspect they se CoG is that for a traffic object, this is explicitly stated:

I could be wrong on that one because traffic objects in CarMaker are significantly more simplified than the ego vehicle.

Regarding the XYZ positions that you use, they are indeed correct, and they use Fr1, which is the hitch projection on the road as you mentioned. CarMaker has an actually Global Navigation Sensor, which is the one I was referencing and would not recommend for this application:

I think your best option at the moment is to place an Inertial sensor at the centre of gravity of the car and use that for position calculation.