Spawn Programmable Camera in Sphinx

Hi, similar to this question, I want to spawn a camera inside my Sphinx simulation. However, in my case, I need to move the camera programmatically. Preferably I would like to do this using ROS. However, the main goal is to:

  1. Stream the data from the camera and access it in a Python script.
  2. Update the cameras position and orientation using a Python script.

Right now, I can modify a world file and place an additional camera inside my scene. For example, I edited empty.world to have the following additional data:

    ...
    ...
    <!--******(THIS IS ORIGINAL CODE)*******-->
    <!--Scene description-->
    <!--*****************-->
    <include>
      <uri>model://sun</uri>
    </include>
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <!--*****(THIS IS NEW CODE)******-->
    <!--Additional Camera-->
    <!--*****************-->
    <model name="additional_camera">
      <static>true</static>
        <link name="link">
          <pose>0.05 0.05 0.05 0 0 0</pose>
          <sensor name="camera" type="camera">
            <camera>
              <horizontal_fov>1.047</horizontal_fov>
              <image>
                <width>320</width>
                <height>240</height>
              </image>
              <clip>
                <near>0.1</near>
                <far>100</far>
              </clip>
            </camera>
            <always_on>1</always_on>
            <update_rate>30</update_rate>
            <visualize>true</visualize>
          </sensor>
        </link>
    </model>

Using the new empty_additional_camera.world file I can launch sphinx using the command below:

$ sphinx <path_to_world_file>/empty_additional_camera.world /opt/parrot-sphinx/usr/share/sphinx/drones/anafi4k.drone::name=other::stolen_interface=::pose="7 0 0.2 0 0 0"::with_front_cam=false

This results in a camera which is viewable in both the editor and in the topics menu, which can be found by clicking Window->Topic Visualization and then selecting the additional camera, example below:

All attempts to control the camera have led me to answers that involve adding a plugin to the additional_camera model. For example this Gazebo tutorial suggests I add the plugin <plugin name="camera_controller" filename="libgazebo_ros_camera.so">. However, when I do this, launching Sphinx results in a segmentation fault. Do you know if there are ways to either:

  1. Have plugins attached to additional cameras in the scene?
  2. Move and access the camera data in a python script?

Thanks!

I should have done more research, but the answer to this problem was already answered in this thread.

My understanding is that problem is that Sphinx currently built on top of Gazebo 7. Thus you need to have a plugin which is compiled for Gazebo 7. To compile your own plugin for Gazebo 7 you need to have the libgazebo7-dev library, which can be installed using:

$ sudo apt-get install libgazebo7-dev

As far as I can tell, there is no way to install libgazebo7-dev on Ubuntu 18. Thus I had to downgrade to Ubuntu 16, and now all works well. I am now able to compile and build Gazebo plugins that can move and access the camera object.

If anyone can install libgazebo7-dev on Ubuntu 18, reply to this thread, and I will mark that as the answer. Otherwise, I am going to mark this as the answer to remove it from the open questions.

EDIT: I really should have done my research, here is another question very similar to this one. Summary is there are no plans to move Sphinx to newer gazebo.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.