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:
- Stream the data from the camera and access it in a Python script.
- 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:
- Have plugins attached to additional cameras in the scene?
- Move and access the camera data in a python script?
Thanks!