morse-simulator / morse

The Modular OpenRobots Simulation Engine
http://morse-simulator.github.io/
Other
351 stars 155 forks source link

VideoCamera messes with scene background #762

Open nicolaje opened 7 years ago

nicolaje commented 7 years ago

Hi guys,

using Blender 2.76, latest build of MORSE (also tested with 1.3), using a VideoCamera sensor makes the background of the scene to be a "view" from another Camera.. To explain, see the following GIF (builder and specific setup is described after)

peek 29-03-2017 14-47

On that .gif:

What I want is not to have that "ghost background" at all, as I have a custom skybox that gets messed up by this. I think it has to do with the "background scene" we can set in the BGE, but couldn't converge to a solution.

Minimal builder file to reproduce the issue:

from morse.builder import *

robot = ATRV()
videocamera = VideoCamera()
robot.append(videocamera)

env = Environment('forssea_sim/data/forssea_sim/environments/test_empty.blend', fastmode=False)

Note that the "ghost background" seems to be pictured by a camera at (0, 0, 0), looking downward. Therefore, it appears only when there are objects below the Blender origin. Attached in the zipfile you will find the .blend file from the GIF.


Edit : same thing happens with any Camera sensor (VideoCamera, DepthCamera, SemanticCamera, Kinect, Velodyne)

test_empty.blend.zip

adegroote commented 7 years ago

It looks like a change in blender internal (we use background scene to render camera since 1.1 I guess). By chance, can you try with an older version of Blender ?

nicolaje commented 7 years ago

I couldn't try with an older version of Blender because of some Python 3.5 incompatibility, but I tested with newer versions of Blender: it starts to "work" again from Blender 2.78.

The VideoCamera seems to be rendering correctly, there seems to be no interaction with the background, however using ROS and trying to set the Simulator view to the VideoCamera view (pressing F9) causes the following error:

[    1.180] Showing view from camera: 'robot.camera.CameraRobot'
Python script error - object 'robot.camera.', controller 'Python':
[ERROR][MORSE] Uncaught exception, quit Blender.
Traceback (most recent call last):
  File "/usr/local/lib/python3/dist-packages/morse/blender/calling.py", line 54, in sensor_action
    component_action(contr)
  File "/usr/local/lib/python3/dist-packages/morse/blender/calling.py", line 50, in component_action
    cmpt_object.action()
  File "/usr/local/lib/python3/dist-packages/morse/core/sensor.py", line 95, in action
    function(self)
  File "/usr/local/lib/python3/dist-packages/morse/middleware/ros/video_camera.py", line 48, in default
    image.data = bytes(image_local)
BufferError: Image buffer is not available
Traceback (most recent call last):
  File "/usr/local/lib/python3/dist-packages/morse/blender/calling.py", line 54, in sensor_action
    component_action(contr)
  File "/usr/local/lib/python3/dist-packages/morse/blender/calling.py", line 50, in component_action
    cmpt_object.action()
  File "/usr/local/lib/python3/dist-packages/morse/core/sensor.py", line 95, in action
    function(self)
  File "/usr/local/lib/python3/dist-packages/morse/middleware/ros/video_camera.py", line 48, in default
    image.data = bytes(image_local)
BufferError: Image buffer is not available

Should I open a new issue for this one?

dgerod commented 7 years ago

Hi,

I am using Blender 2.71, so I am trying to help. However, when I open your .blend file there is only a cube, see the picture.

file_with_blender-2 71

Could you said me what I have to do exactly to reproduce the issue?

My configuration is:

nicolaje commented 7 years ago

Hi @dgerod ,

to reproduce the issue you have to use that builder script:

from morse.builder import *

robot = ATRV()
videocamera = VideoCamera()
robot.append(videocamera)

env = Environment('path/to/the/blend/file/test_empty.blend', fastmode=False)

with the .blend file provided (containing indeed only one cube).

I think with newer versions of Blender the Camera need some reworking, but currently this is a bit over my Blender-fu ...

PierrickKoch commented 7 years ago

Hello @nicolaje and @dgerod !

Since we don't have much time lately to manage PR and code review, I've just added both of you in the Developers group on morse-simulator organization ;-)

Welcome aboard, feel free to push/merge (preferably after squashing), and thank you for your contributions ;-)

dgerod commented 7 years ago

Thanks @pierriko :-)

Although I am quite busy with several things, I would try to do my best helping here.

dgerod commented 7 years ago

@nicolaje, I have just tested your script and there is the problem, see below the screen-shots:

Using "MORSE edit" test_in_morse-edit_1 test_in_morse-edit_2 Using "MORSE run" test_in_morse-run

My configuration is: MORSE: 1.4-40-g0c24d-dirty Blender: v.2.71.0 Python: 3.4.0

nicolaje commented 7 years ago

Thanks Pierrick!

Diego, now if you try with Blender 2.78 that artifact will be gone, but if you press F9 to see from the camera view while publishing the camera's frames over ROS, you will get the Image Buffer error above.

crey0 commented 6 years ago

Hi, I observed the same behavior when pressing F9. I am running simulation in fixed timestep mode.

Pressing F9: Blender <1.78: The timestamp of the next image is shifted by one simulation step. Blender =1.79: Same (next image misses one simulation step), buffer error in the ROS callback.