0

I try to get the depth image of a Kinect camera using Python. The webots can detect Kinect device successfully and can enable it too. but, when I try to use getRangeImage function to get the depth values, the controller is crashed. My code is as follows:

self.kinectrange=self.getRangeFinder("kinect range")
self.kinectrange.enable(timestep)
image=self.kinectrange.getRangeImage ()

What is the problem? O.S : windows 10 Webots: R2019a revision 1

Farzaneh
  • 1
  • 1
  • 1
    I am sorry but I am not able to reproduce the problem on R2019a revision 1, I tested with this controller (inspired from your code): https://gist.github.com/DavidMansolino/b95442478c4195dc72022b058758fbf6 This controller prints 'None' which is to be expected since a 'robot.step(timestep)' is expected between the call to 'kinectrange.enable' and 'kinectrange.getRangeImage'. Your controller is probably crashing because you are trying to process this None image. – David Mansolino Mar 01 '19 at 09:45
  • Thanks for your attention, I checked the following code in my controller: image=self.kinectrange.getRangeImage() print(image) the output image is not null but after adding the following code the controller still crashed : kinectvalue=self.kinectrange.rangeImageGetDepth(image,320 , 5, 5) – Farzaneh Mar 03 '19 at 09:42
  • Did you try to add the step after enabling the range finder (https://gist.github.com/DavidMansolino/b95442478c4195dc72022b058758fbf6#file-my_controller-py-L9) ? – David Mansolino Mar 04 '19 at 09:48
  • Yes, I also checked other conditions , I added another step before using rangeImageGetDepth function: robot.kinectrange = robot.getRangeFinder("kinect range") robot.kinectrange.enable(timestep) robot.step(timestep) image = robot.kinectrange.getRangeImage() robot.step(timestep) kinectvalue=robot.kinectrange.rangeImageGetDepth(image,200 , 5, 5) print(kinectvalue) the print showed a value but controller still crashed.before, getRangeImage command had problem and now rangeImageGetDepth – Farzaneh Mar 04 '19 at 11:39
  • Can you post (maybe on https://gist.github.com/) the complete code of your controller with the step? – David Mansolino Mar 06 '19 at 09:41
  • I used your code which attached above -->(gist.github.com/DavidMansolino/…), and yes, as you said, your code does not have any problem. but I added another line to the end of this code as below: kinectvalue=robot.kinectrange.rangeImageGetDepth(image,320, 5, 5) using this line makes the controller crashed. – Farzaneh Mar 06 '19 at 10:25
  • The complete code of my controller: https://gist.github.com/ft2019/4a00307a63626005c40f70eeab20ec4d – Farzaneh Mar 06 '19 at 20:22
  • Dear David, I'm still waiting for your answer. Thanks – Farzaneh Apr 12 '19 at 17:07
  • I am sorry for the late answer, I didn't saw the notification about your message until now. I checked your example and everything is working fine: https://i.ibb.co/QNP9qkZ/Capture-du-2019-04-15-08-44-48.png Are you sure you are using the latest version of Webots? – David Mansolino Apr 15 '19 at 06:46
  • I checked the version of the used Webots, it was 2019a revision1. I do not find the problem. here I uploaded my project entirely: https://github.com/ft2019/Kinect_Webots. Could you please use my project to see the problem. Thanks in advance. – Farzaneh Apr 16 '19 at 06:57
  • I am sorry, but once again I tried your example and it is working fine, please see: https://i.ibb.co/G2yGGnr/Capture-du-2019-04-16-09-09-03.png Maybe you should try to use a different version of Python. – David Mansolino Apr 16 '19 at 07:10
  • I did another test and I could find the problem. If the controller tries to execute the highlighted instruction in image:https://github.com/ft2019/Kinect_Webots/blob/ErrorImage/Capture.PNG for the same i and j value, it will crash! – Farzaneh Apr 16 '19 at 10:33
  • Thanks a lot for your attention. I use python 3.7.1. Could you please let me know which version of python you use? – Farzaneh Apr 17 '19 at 07:10
  • I tried python 2.7.9, 2.7.13, 2.7.16, 3.6, and 3.7.1. But the problem still exists. The following error has been occurred using python 2.7.9: kinectvalue=self.kinectrange.rangeImageGetDepth(image,320 , i, j) [ctrlKinect] TypeError: in method 'Camera_rangeImageGetValue', argument 2 of type 'PyList' of 'PyFloat' WARNING: 'ctrlKinect' controller crashed. – Farzaneh Apr 27 '19 at 06:21
  • Dear David, Could you please let me know which version of python you use? – Farzaneh May 04 '19 at 06:29
  • I am using Python 2.7.12, but this should work with any version of Python 2.7.x, 3.5.x, 3.6.x and 3.7.x – David Mansolino May 06 '19 at 06:31
  • https://github.com/ft2019/Kinect_Webots/blob/master/controllers/ctrlKinect/ctrlKinect.py – Farzaneh May 21 '19 at 08:20

0 Answers0