Header Overview

This tutorial shows you, how to receive your first variables from the device.

Code

Let us take a look at the code. I did some changes:

I removed requesting the ACI version infos, because we don't need it anymore. Our main aim is to receive the pitch, roll and yaw angle 100 times per second. After initializing ACI, I request also the variable list.

That is a list, which is defined on the device. It includes all available read-only variables on the device with a constant description, unit and type and a changing value. You need to call the list at least once, that your remote knows the available variables. You can then read them e.g. with aciGetVariableItemByIndex(unsigned short index). You can call the list also after starting the thread. It can take a while until all variables are received. Then, the variable list update callback will be executed:

If you use an unmodified version of the AscTec SDK 3.0, you will get the list of variables listed here. Otherwise, you can also use the function aciGetVariableItemByIndex(unsigned short index) to get every listed variable by counting the index up until the function returns NULL. We know from the list of all predefined variables, commands and parameters, that the variable with the id 0x3000, 0x3001 and 0x3002 are the pitch, roll and yaw angle, which are 32-bit integers. We add this content to the variable packet with the id 0. Afterwards, we set the transmission rate for packet 0 to 1000/10=100 calls per second with aciSetVarPacketTransmissionRate(0,10); and send that and the packet 0 configuration to the device. Then, the device is sending automatically the packet 0. In the aciThread, I wrote an output code, that prints the angles on the console:

Every time, when we receive a variable, it will be saved in a receiving buffer. Only when you call aciSynchronizeVars(), the content of the buffer will be copied in the variables you set up. After compiling and executing the code, you get the following output:

With using the timecounter variable in the aciThread, you get only every second a new output. Although you receive the angles with 100Hz, you only update it one time per second in your variables. That is the reason, why the angles before synchronizing are the same like one second before. So every time, when you want to calculate with new variables, you have to synchronize it.

In the next step you will find out how to send commands.