Robotics StackExchange | Archived questions

Encoding matches, integer turns float

Hello I am combining the ensenso ros driver with the mask rcnn ros node. I'm using ros kinetic with the master branch of both packages. I am using an RTX 2080 ti and ubuntu 16.04 with kernel 4.15.0-46-generic.

I have altered the code for the mask rcnn node to accept my own trained data and to accept a mono8 image encoding as input, the input image is stacked onto itself to create a fake bgr image. I have tested this against the bagfile that is included as an example and it is still operational. I created my own launch file:

<launch>
  <arg name="configuratie" value="$(find ensenso_camera)/configs/configuratie.json"/>
  <node pkg="ensenso_camera" type="ensenso_camera_node" name="ensenso_camera_node">
    <param name="settings" value="$(arg configuratie)"/>
  </node>
  <node pkg="ensenso_camera" type="request_data" name="image_stream_node">
    <param name="request_rectified_images" value="true"/>
    <param name="publish_results" value="true"/>
  </node>
  <node pkg="tf" type="static_transform_publisher" name="ensenso_optical_frame" 
    args="0 0 0 0 0 0 world ensenso_optical_frame 100"/>
  <node pkg="mask_rcnn_ros" type="mask_rcnn_node" name="mask_rcnn">
    <remap from="~input" to="/rectified/left/image"/>
    <param name="~visualization" value="true"/>
  </node>
</launch> 

However, when I launch my launch file, where the both the camera and the model node are started and have their out and input mapped to each other, the model gives the following error:

Traceback (most recent call last):
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/nodes/mask_rcnn_node", line 182, in <module>
    main()
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/nodes/mask_rcnn_node", line 179, in main
    node.run()
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/nodes/mask_rcnn_node", line 104, in run
    results = self._model.detect([np_image], verbose=0)
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/src/mask_rcnn_ros/model.py", line 2333, in detect
    molded_images, image_metas, windows = self.mold_inputs(images)
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/src/mask_rcnn_ros/model.py", line 2236, in mold_inputs
    padding=self.config.IMAGE_PADDING)
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/src/mask_rcnn_ros/utils.py", line 402, in resize_image
    image, (round(h * scale), round(w * scale)))
  File "/home/riwo-rack-pc/.local/lib/python2.7/site-packages/scipy/misc/pilutil.py", line 490, in imresize
    imnew = im.resize(size, resample=func[interp])
  File "/home/riwo-rack-pc/.local/lib/python2.7/site-packages/PIL/Image.py", line 1806, in resize
    return self._new(self.im.resize(size, resample, box))
TypeError: integer argument expected, got float
[mask_rcnn-5] process has died [pid 2784, exit code 1, cmd /home/riwo-rack-pc/ROS_Mask_rcnn/src/mask_rcnn_ros/nodes/mask_rcnn_node ~input:=/rectified/left/image __name:=mask_rcnn __log:=/home/riwo-rack-pc/.ros/log/22188f46-5131-11e9-b28a-049226d3501e/mask_rcnn-5.log].
log file: /home/riwo-rack-pc/.ros/log/22188f46-5131-11e9-b28a-049226d3501e/mask_rcnn-5*.log

Mask_rcnn-5.log states:

rospy.client][INFO] 2019-03-28 09:11:50,034: init_node, name[/mask_r$
[xmlrpc][INFO] 2019-03-28 09:11:50,035: XML-RPC server binding to 0.0$
[xmlrpc][INFO] 2019-03-28 09:11:50,035: Started XML-RPC server [http:$
[rospy.init][INFO] 2019-03-28 09:11:50,035: ROS Slave URI: [http://ri$
[rospy.impl.masterslave][INFO] 2019-03-28 09:11:50,035: _ready: http:$
[rospy.registration][INFO] 2019-03-28 09:11:50,036: Registering with $
[xmlrpc][INFO] 2019-03-28 09:11:50,036: xml rpc node: starting XML-RP$
[rospy.init][INFO] 2019-03-28 09:11:50,136: registered with master
[rospy.rosout][INFO] 2019-03-28 09:11:50,136: initializing /rosout co$
[rospy.rosout][INFO] 2019-03-28 09:11:50,138: connected to core topic$
[rospy.simtime][INFO] 2019-03-28 09:11:50,139: /use_sim_time is not s$
[tensorflow][WARNING] 2019-03-28 09:11:50,166: From /home/riwo-rack-p$
Instructions for updating:
Colocations handled automatically by placer.
[rospy.internal][INFO] 2019-03-28 09:11:50,380: topic[/rosout] adding$
[tensorflow][WARNING] 2019-03-28 09:11:52,647: From /home/riwo-rack-p$
Instructions for updating:
keep_dims is deprecated, use keepdims instead
[tensorflow][WARNING] 2019-03-28 09:11:52,651: From /home/riwo-rack-p$
Instructions for updating:
keep_dims is deprecated, use keepdims instead
[tensorflow][WARNING] 2019-03-28 09:11:53,111: From /home/riwo-rack-p$
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, use
    tf.py_function, which takes a python function which manipulates t$
    tensors instead of numpy arrays. It's easy to convert a tf eager $
    an ndarray (just call tensor.numpy()) but having access to eager $
    means `tf.py_function`s can use accelerators such as GPUs as well$
    being differentiable using a gradient tape.

[rospy.internal][INFO] 2019-03-28 09:11:58,820: topic[/rectified/left$
[rospy.core][INFO] 2019-03-28 09:11:58,968: signal_shutdown [atexit]
[rospy.internal][INFO] 2019-03-28 09:11:58,971: topic[/rosout] removi$
[rospy.internal][INFO] 2019-03-28 09:11:58,972: topic[/rectified/left$
[rospy.internal][WARNING] 2019-03-28 09:11:58,972: Unknown error init$
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/ros_comm/clients/rospy/s$
    self.read_header()
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/ros_comm/clients/rospy/s$
    self._validate_header(read_ros_handshake_header(sock, self.read_b$
AttributeError: 'NoneType' object has no attribute 'buff_size'

[rospy.topics][ERROR] 2019-03-28 09:11:58,973: Traceback (most recent$
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/ros_comm/clients/rospy/s$
    c.close()
  File "/home/riwo-rack-pc/ROS_Mask_rcnn/src/ros_comm/clients/rospy/s$
    self.socket.close()
AttributeError: 'NoneType' object has no attribute 'close'

[rospy.impl.masterslave][INFO] 2019-03-28 09:11:58,973: atexit

The camera sends its image with the sensor_msgs/Image message and the model expects this message format as well. This format does not contain floats, so my guess is that this float is created somewhere in the trace but I can not find it. I have tried to add print statements to follow the code but this does not work as the node is simply shutdown.

What could cause this problem? I recon it can not be a python 2 vs 3 issue. I know ROS 1 runs on python 2.7, the original model code runs on python 3, however the ROS nodes functions perfectly fine until I add my camera, there it must have been altered to work inside ROS with python 2. If my memory serves me right python 3 was only needed for the training aspect. Again the encoding matches up, and should not consist of float's as i understand it. What could cause this behavior is a total mistery to me.

If this question would be better asked on stackoverflow instead of here my apologies.

Thanks in advance to the person that can relieve this ongoing headache of mine!

Asked by THordijk on 2019-03-28 03:46:42 UTC

Comments

I have altered the code for the mask rcnn node to accept my own trained data and to accept a mono8 image encoding as input, the input image is stacked onto itself to create a fake bgr image.

that would be the first thing to check. The code was not written for mono images, you changed it.

Asked by gvdhoorn on 2019-03-28 05:17:37 UTC

Answers