# voxl-cam-ros

Source: https://forum.modalai.com/topic/12/voxl-cam-ros
Category: VOXL SDK and Software (https://forum.modalai.com/category/47/voxl-sdk-and-software)
Posted: 2020-09-28 21:58:09 UTC by vaughanje
Replies: 11 · Views: 2959

## vaughanje · 2020-09-28 21:58:09 UTC

I'm currently working on a VOXL Flight-based system. The forward facing camera is connected to the J2 port on the VOXL. I am able to get a stream from it in QgroundControl, but cannot seem to get the `voxl_cam_ros` package to run. It never connects to the camera, so the node fails after a timeout. I've tried a variety of options when running roslaunch, but with no success.

Is there anything obvious that I might be missing? Common mistakes that I should check that I'm not making?

The output of `voxl-version` is:

    --------------------------------------------------------------------------------
    system-image:    ModalAI 2.2.0 BUILDER: ekatzfey BUILD_TIME: 2020-01-28_23:54
    kernel:          #1 SMP PREEMPT Tue Jan 28 23:55:02 UTC 2020 3.18.71-perf
    factory-bundle:  0.0.5
    sw-bundle:       0.0.5
    --------------------------------------------------------------------------------
    architecture:    aarch64
    processor:       apq8096
    os:              GNU/Linux
    --------------------------------------------------------------------------------
    voxl-utils:
    Package: voxl-utils
    Version: 0.4.6
    Status: install user installed
    Architecture: aarch64
    Installed-Time: 246
    
    --------------------------------------------------------------------------------

Thank you.

## Reply by modaltb (ModalAI staff) · 2020-09-28 23:12:06 UTC

Using this as reference: https://docs.modalai.com/voxl-cam-ros/

These scripts use some environment variables that have tripped me up before, for tracking:

https://gitlab.com/voxl-public/voxl-cam-ros/-/blob/master/launch/tracking.launch#L7

Can you run `voxl-env show` ?

`TRACKING_CAM_ID`needs to match that of the launch file.

You can use `voxl-configure-cameras` to modify if needed.

## Reply by vaughanje · 2020-09-29 20:47:36 UTC

The content of `voxl-env show` is:

```
ROS_MASTER_URI=http://localhost:11311/
ROS_IP=192.168.8.1
CAM_CONFIG_ID=2
HIRES_CAM_ID=-1
TRACKING_CAM_ID=0
STEREO_CAM_ID=-1
TOF_CAM_ID=-1
```

This was after running `voxl-configure-cameras` to change to the tracking camera only configuration. However, given that the camera is connected to J2, should I use the hires camera? I'm basing this question on the information here: 

https://docs.modalai.com/voxl-flight-quickstart/

which reports the J2 connector as the hires camera. Should I use a hires camera configuration? I have tried both without success, but if I'm asking to make sure that I do have the correct camera configuration. That would help me narrow the issue on my side.

## Reply by Chad Sweet (ModalAI staff) · 2020-09-29 20:50:06 UTC

When you look at the RTSP stream, is it in color? Trying to understand what setup you have. The config implies you have a single, high-resolution camera connected. Since voxl-rtsp is working, the camera is working. It looks like if you have voxl-cam-ros use camera ID 1, it should work

## Reply by vaughanje · 2020-09-29 21:46:10 UTC

Yes. I get color images from the RTSP stream. 

We do currently only have a single camera, connected to J2.

## Reply by James Strawson (ModalAI staff) · 2020-09-29 22:56:17 UTC (in reply to vaughanje)

@vaughanje 

voxl-configure-cameras doesn't have a hires-only option but option #4 (hires + tracking) should work for you. Any option that sets the HIRES_CAM_ID to 0 which will be it's index if it's the only camera connected. You also need to make sure the "ROS_IP" variable is set correctly in ~/my_ros_env.sh otherwise roscore will fail to start and no nodes will start. That's just a fun feature of ROS that it needs to know its own IP address before starting even when only running nodes locally.

 After running voxl-configure-cameras or updating ~/my_ros_env.sh make sure to refresh the new bash environment variables with "exec bash"

The ROS node needs to be run in either master mode if running alone, or slave mode if the rtsp streamer was started first. The ROS node cannot be started before the RTSP stream. The command to launch the hires cam in master mode is:

roslaunch voxl_cam_ros hires.launch
OR
roslaunch voxl_cam_ros hires_color.launch

To run as slave:
roslaunch voxl_cam_ros hires.launch is_cam_master:=false
OR
roslaunch voxl_cam_ros hires_color.launch is_cam_master:=false

Regards,
James

## Reply by vaughanje · 2020-09-30 14:49:26 UTC

Thanks for the help.

I reverted to using the hires + tracking option. So, the current output of `voxl-env show` is:

```
ROS_MASTER_URI=http://localhost:11311/
ROS_IP=192.168.8.1
CAM_CONFIG_ID=4
HIRES_CAM_ID=0
TRACKING_CAM_ID=1
STEREO_CAM_ID=-1
TOF_CAM_ID=-1
```

The RTSP stream is running, so I used the `is_cam_master:=false` version of the suggested `roslaunch` commands. There is a pause between `libcam.dump.dir /data/misc/camera/dumps` and `ERROR: could not open camera subscriber for cam id 0`.

```
SUMMARY
========

PARAMETERS
 * /hires/voxl_cam_nodelet/cam_id: 0
 * /hires/voxl_cam_nodelet/cam_name: hires
 * /hires/voxl_cam_nodelet/format: 1
 * /hires/voxl_cam_nodelet/frame_id: hires_frame
 * /hires/voxl_cam_nodelet/frame_rate: 15
 * /hires/voxl_cam_nodelet/height: 1080
 * /hires/voxl_cam_nodelet/is_cam_master: False
 * /hires/voxl_cam_nodelet/skip_n_frames: 0
 * /hires/voxl_cam_nodelet/width: 1920
 * /hires/voxl_cam_nodelet/yuv_remap: yuv422
 * /rosdistro: indigo
 * /rosversion: 1.11.21

NODES
  /hires/
    hires_nodelet_manager (nodelet/nodelet)
    voxl_cam_nodelet (nodelet/nodelet)

auto-starting new master
process[master]: started with pid [4890]
ROS_MASTER_URI=http://localhost:11311/

setting /run_id to da98c2d4-1dd3-11b2-913f-ec5c68cd238b
process[rosout-1]: started with pid [4903]
started core service [/rosout]
process[hires/hires_nodelet_manager-2]: started with pid [4916]
process[hires/voxl_cam_nodelet-3]: started with pid [4921]
[ INFO] [764.624133042]: Initializing nodelet with 4 worker threads.
[ INFO] [764.819000074]: SnapCamDriver Starting
[ INFO] [764.819231792]: Monotonic offset: 1.670465990
libcam.enable.publish  1
libcam.enable.publish.dump 0
libcam.publish.buffer.policy max
libcam.publish.buffer.max 3
libcam.debug.level info
libcam.dump.dir /data/misc/camera/dumps
ERROR: could not open camera subscriber for cam id 0
[ERROR] [781.824676109]: CameraManager::Initialize() failed
[ERROR] [781.825179598]: Unable to open camera.
```

Any ideas?

## Reply by Chad Sweet (ModalAI staff) · 2020-10-01 04:56:10 UTC

Can you try the camera-test app? See if you can find a camera ID that enumerates as high-res. Maybe it's not actually located at ID 0 (the ID can change based on which cameras are connected)

## Reply by vaughanje · 2020-10-01 17:19:06 UTC

Running `camera-test` gives:

```
num_cameras = 1
Testing camera id=0
Segmentation fault
```

## Reply by Chad Sweet (ModalAI staff) · 2020-10-02 21:22:15 UTC

It seems voxl-rtsp cannot run concurrently with voxl-cam-ros. We are working on a new camera-server to fan out the cameras more consistently, but that is probably a month away. 

voxl-cam-ros uses libCamera which does support multiple clients of the same camera. It would be possible to write an rtsp server using the built in live555 and libCamera that would work concurrently with voxl-cam-ros. 

Otherwise it seems in the meantime you will need to disable voxl-rtsp to get voxl-cam-ros to work

## Reply by vaughanje · 2020-10-19 14:16:55 UTC

Sorry for the slight delay. I was finally able to get back to this this morning. Killing `voxl-rtsp` fixed this issue. `voxl-cam-ros` will launch without issue. Thank you for the help.

## Reply by ptaylor1234 · 2021-06-17 19:47:47 UTC (in reply to vaughanje)

@vaughanje I am with you up until this point, but I can't figure out how to kill `voxl-rtsp`. what command did you use for that?
