# How to receive GPS information in voxl-tflite-server?

Source: https://forum.modalai.com/topic/960/how-to-receive-gps-information-in-voxl-tflite-server
Category: Flight Core and Legacy VOXL (https://forum.modalai.com/category/9/flight-core-and-legacy-voxl)
Tags: voxl
Posted: 2022-05-25 07:35:17 UTC by Nguyen Tien Su
Replies: 8 · Views: 1192

## Nguyen Tien Su · 2022-05-25 07:35:17 UTC

I need to have GPS information such as latitude, and longitude, ... to process in voxl-tflite-server c++ code. How can I do it?

## Reply by Guest · 2022-05-25 16:14:04 UTC

Hello @Nguyen-Tien-Su,

voxl-inspect-gps (https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/blob/master/tools/voxl-inspect-gps.c) is an example of how to subscribe to the gps pipe and process the data.

## Reply by Nguyen Tien Su · 2022-05-26 02:26:47 UTC

Thank you, @Matt-Turi !
I checked the code and understood. But it's error when I include mavlink.h header file from c_library_v2 library into voxl-tflite-server. It said that mavlink.h file not found. How can I solve this problem?

## Reply by Guest · 2022-05-26 16:55:31 UTC

To use the mavlink headers, you must add voxl-mavlink to the required dependencies for the project. This can be done by modifying the install_build_deps.sh script, and simply adding voxl-mavlink to the DEPS_* list depending on your platform. 
```
DEPS_QRB5165="
libmodal-pipe
libmodal-json
voxl-opencv
voxl-mavlink  
qrb5165-tflite"

DEPS_APQ8096="
libmodal-pipe
libmodal-json
voxl-opencv
voxl-mavlink
apq8096-tflite"

## Reply by Nguyen Tien Su · 2022-05-31 02:16:58 UTC

Thank @Matt-Turi very much !
I am successful to receive GPS in voxl-tflite-server. But I can't open 2 pipes GPS and TFLITE at the same time since they use same channel 0. Their channel seems to be set up by the MPA and can't change. How can I solve this problem?

## Reply by Guest · 2022-05-31 16:14:20 UTC

@Nguyen-Tien-Su,
Did you experience any error messages when you tried this? Subscribing to the gps pipe should be independent of any channels/pipes that the tflite-server opens, as gps is a client connection. See here: https://gitlab.com/voxl-public/voxl-sdk/services/voxl-tflite-server/-/blob/master/src/main.cpp#L344 for an example of opening up a client connection and getting the next avaialble channel automatically using
```
int ch = pipe_client_get_next_available_channel();
```

## Reply by Nguyen Tien Su · 2022-06-01 02:09:22 UTC

Hi @Matt-Turi ! This is error.

![2bb3a8ec-babe-4fe5-b027-b329421355e7-image.png](https://forum.modalai.com/assets/uploads/files/1654049212078-2bb3a8ec-babe-4fe5-b027-b329421355e7-image.png) 

I tried to change the channel of GPS, then I can't receive any GPS message. I also tried to change channel of the TFLITE server but it couldn't start.

## Reply by Guest · 2022-06-01 16:21:26 UTC

Make sure you are setting the callback functions correctly with the next available channel (rather than hardcoding to 0). The tflite-server is only opening one client connection to receive camera frames, so it should be simple to avoid a channel conflict. 

If your callback functions are named the same as the inspect-gps example, this code could be pasted in after line https://gitlab.com/voxl-public/voxl-sdk/services/voxl-tflite-server/-/blob/master/src/main.cpp#L354
```
int ch = pipe_client_get_next_available_channel();

pipe_client_set_simple_helper_cb(ch, _helper_cb, NULL);
pipe_client_set_connect_cb(ch, _connect_cb, NULL);
pipe_client_set_disconnect_cb(ch, _disconnect_cb, NULL);

int ret = pipe_client_open(ch, GPS_RAW_OUT_PATH, PROCESS_NAME, \
          EN_PIPE_CLIENT_SIMPLE_HELPER | EN_PIPE_CLIENT_AUTO_RECONNECT, \
	  sizeof(mavlink_message_t));

```

## Reply by Nguyen Tien Su · 2022-06-02 09:12:47 UTC

Hi @Matt-Turi !
You right. I hardcoded tflite server channel, so I forgot to change it when setting callback function. Now, my code works fine.
Thank you very much for your enthusiastic help!
