# VOXL MPA_TO_ROS Topic publishing

Source: https://forum.modalai.com/topic/3227/voxl-mpa_to_ros-topic-publishing
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2024-03-18 04:05:42 UTC by Darshit Desai
Replies: 9 · Views: 1396

## Darshit Desai · 2024-03-18 04:05:42 UTC

Hi Is there a way to publish only a selected few topics using the voxl_mpa_to_ros_node, right now it publishes a lot of topics which I am not using and it might be slowing down the rest of my application. If there is either a way to block topics like hires_camera_image and other topics like /tof_ir, /tof_conf using cli or some code changes by modifying the package please let me know

## Reply by Eric Katzfey (ModalAI staff) · 2024-03-18 15:41:27 UTC

@Darshit-Desai Have you looked at the voxl_mpa_to_ros code? Can you see how it is setting these things up?

## Reply by Darshit Desai · 2024-03-18 16:06:41 UTC (in reply to Eric Katzfey)

@Eric-Katzfey I can have a look at the code and could also clone the package available on gitlab modify it in my loc catkin_ws and use that. My question was is there a direct way by changing some .conf file or maybe a launch file inside the mpa_to_ros package or do I need to delete the topic advertisements from the code

## Reply by Alex Kushleyev (ModalAI staff) · 2024-03-18 19:01:43 UTC (in reply to Darshit Desai)

@Darshit-Desai ,

There is already some logic that monitors if number of ROS subscribers to a particular topic is zero or greater. If it is zero, the publishing of ROS messages should stop. 

https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-to-ros/-/blob/master/catkin_ws/src/src/interface_manager.cpp?ref_type=heads#L265

However, it seems, the MPA clients are still going to receive the data into the mpa callback (but exits before publishing, if there are no ROS clients):

https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-to-ros/-/blob/master/catkin_ws/src/src/interfaces/camera_interface.cpp?ref_type=heads#L95

If you wanted to completely stop the data flow to the mpa_to_ros node, the existing interfaces in this project would need to close the pipe (using `pipe_client_close()` ) if there are no ROS clients for that particular interface. Then the pipe would need to be re-opened again once the ROS clients subscribe again.

## Reply by Darshit Desai · 2024-03-18 19:22:31 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev interesting, I will have a look there. I saw in the documentation that I can also subscribe to specific libmodal pipes, but it was mentioned only for C code, is there a possibility I could use the data streamed on those pipes directly in my c++ code, I would eliminate a whole lot of code debugging which I need to do with the mpa_to_ros node

In my current setup, I only subscribe to /tflite_data (tflite uses hires_small_grey image internally) , /tof_pc.

In this scenario I would still be using Ros to publish some data using the same c++ file

## Reply by Alex Kushleyev (ModalAI staff) · 2024-03-18 19:28:31 UTC (in reply to Darshit Desai)

@Darshit-Desai ,

You can use the MPA C interface directly in C++, for example the mpa_to_ros interface / node is written in C++. 

If you wanted to quickly disable some interfaces in the mpa_to_ros node, you can do it here: https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-to-ros/-/blob/master/catkin_ws/src/src/interface_manager.cpp?ref_type=heads#L118 - this part of the code queries the list of all available pipes and creates interfaces for all the pipes that have ROS interfaces written for them. You can just comment out the ones that you don't need.

What other data would you want to stream via MPA directly (and where would you want to send it? is it within VOXL2 or external PC?)

## Reply by Darshit Desai · 2024-03-18 19:54:45 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev so essentially everything inside the switch case from line#191 to #205 in the file you linked above 

Everything is supposed to be processed on voxl2 no external PC is involved yet. That's why I was thinking if I could directly just get the tof_pc and the tflite_data. Also the AI detection interface also publishes the bounding box draw on the image to Ros topic and the voxl-portal using the hires_small_grey image what if I want to disable that too, since I have validated my Neural net functionality already and for the functioning of my algorithm I just need the bbox coordinates.

Also the pointcloudinterface would still publish the /tof_conf, /tof_depth and /tof_ir images, that is also extra processing being done by the node which I don't need

## Reply by Alex Kushleyev (ModalAI staff) · 2024-03-18 20:19:35 UTC (in reply to Darshit Desai)

@Darshit-Desai , you should take a look at the source code of the inspect tools that we have written : 

https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/tree/master/tools

They provide many examples of simple MPA clients. You can make your own tools based on these, the easiest way is just to utilize this project (build environment, etc), just add a new executable that does what you need and add a few lines to CMakeLists.txt to build it.

## Reply by Darshit Desai · 2024-03-25 21:46:08 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev Hi I have been trying to build my modified mpa to ros package in voxl-cross but it seems like it isn't installting dependencies properly Here is the terminal output

```BASH
voxl-cross(2.7):~((sdk-1.1.0))(0.3.7)$ ./install_build_deps.sh qrb5165 sdk-1.
sdk-1.0  sdk-1.1  
voxl-cross(2.7):~((sdk-1.1.0))(0.3.7)$ ./install_build_deps.sh qrb5165 sdk-1.1 
using qrb5165 sdk-1.1 debian repo
Ign:1 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ InRelease
Ign:2 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ Release
Get:3 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ Packages [23.0 kB]
Fetched 23.0 kB in 0s (59.7 kB/s)
Reading package lists... Done
installing: 
libmodal-json
libmodal-pipe
libvoxl-cutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libmodal-json:arm64 libmodal-pipe:arm64 libvoxl-cutils:arm64
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 136 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ libmodal-json 0.4.3 [43.8 kB]
Get:2 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ libmodal-pipe 2.9.2 [85.9 kB]
Get:3 http://voxl-packages.modalai.com ./dists/qrb5165/sdk-1.1/binary-arm64/ libvoxl-cutils 0.1.1 [6228 B]
Fetched 136 kB in 0s (299 kB/s)                
Selecting previously unselected package libmodal-json:arm64.
(Reading database ... 30777 files and directories currently installed.)
Preparing to unpack .../libmodal-json_0.4.3_arm64.deb ...
Unpacking libmodal-json:arm64 (0.4.3) ...
Selecting previously unselected package libmodal-pipe:arm64.
Preparing to unpack .../libmodal-pipe_2.9.2_arm64.deb ...
Unpacking libmodal-pipe:arm64 (2.9.2) ...
Selecting previously unselected package libvoxl-cutils:arm64.
Preparing to unpack .../libvoxl-cutils_0.1.1_arm64.deb ...
Unpacking libvoxl-cutils:arm64 (0.1.1) ...
Setting up libvoxl-cutils:arm64 (0.1.1) ...
Setting up libmodal-json:arm64 (0.4.3) ...
Setting up libmodal-pipe:arm64 (2.9.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...

Done installing dependencies

voxl-cross(2.7):~((sdk-1.1.0))(0.3.7)$ ./clean.sh 
voxl-cross(2.7):~((sdk-1.1.0))(0.3.7)$ ./build.sh qrb5165 
./build.sh: line 46: /opt/ros/melodic/setup.bash: No such file or directory
voxl-cross(2.7):~((sdk-1.1.0))(0.3.7)$
```

On the readme it does say to use `sudo voxl-docker -i voxl-emulator` this command but I don't have the emulator installed so I am using voxl-cross instead

## Reply by Alex Kushleyev (ModalAI staff) · 2024-03-25 22:42:09 UTC (in reply to Darshit Desai)

@Darshit-Desai , if you don't have the emulator docker, the next best thing to do is to build the package right on target, using `./build.sh native` option. please try.
