Extend-Robotics / camera_aravis

A ROS1 driver for GenICam based GigE and USB3 cameras.
Other
1 stars 1 forks source link

corrupted data when manipulating MTU at runtime #25

Closed bmegli closed 1 year ago

bmegli commented 1 year ago

Sometimes when manipulating MTU data is corrupted afterwards

image

bmegli commented 1 year ago

Related to #24

bmegli commented 1 year ago

Current workaround if problem happens is to restart the node

bmegli commented 1 year ago

Another workaround is not to change MTU but in some scenarios it is necessary

bmegli commented 1 year ago

It looks like device remembers MTU

I can see it in output

[ INFO] [1696942328.057653062]:     Network mtu          = 9000

And it is value set last time when launching node

bmegli commented 1 year ago

Above comes from

  if (implemented_features_["GevSCPSPacketSize"])
    ROS_INFO("    Network mtu          = %lu", aravis::device::feature::get_integer(p_device_, "GevSCPSPacketSize"));

Which confirms it's readout from device

bmegli commented 1 year ago

Logic on dynamic reconfigure change

 if (changed_mtu)
  {
    if (implemented_features_["GevSCPSPacketSize"])
    {
      ROS_INFO("Set mtu = %d", config.mtu);
      aravis::device::feature::set_integer(p_device_, "GevSCPSPacketSize", config.mtu);
      ros::Duration(1.0).sleep();
      config.mtu = aravis::device::feature::get_integer(p_device_, "GevSCPSPacketSize");
      ROS_INFO("Get mtu = %d", config.mtu);
    }
    else
      ROS_INFO("Camera does not support mtu (i.e. GevSCPSPacketSize).");
  }
bmegli commented 1 year ago

It also looks like apart from dynamic reconfigure MTU there is also initially setup value from ROS parameter

  pnh.param<int>("mtu", config_.mtu, config_.mtu);

This value seems to be happily ignored later (overwritten by dynamic reconfigure default?)

At the same time device may have different MTU from above 2 values.

What a mess.

bmegli commented 1 year ago

Reproducible

  1. From cold booted MotionCam3D and ROS PC
  2. Modify MTU on ROS PC OS side
sudo ifconfig enp60s0 mtu 9000
  1. Start ROS driver

  2. Wait until camera initializes

  3. Modify MTU on MotionCam3D ROS driver

rosrun rqt_reconfigure rqt_reconfigure
# set to matching 9000
  1. Request depth and raw image

Restart of ROS driver fixes the problem

bmegli commented 1 year ago

OS MTU doesn't need to be changed after starting the driver for the problem to manifest

Updating above

bmegli commented 1 year ago

After fixing setting up MTU from rosparam in:

I can now initialize with selected MTU from cold booted MotionCam3D and ROS without corrupted data

bmegli commented 1 year ago

Now that MTU was removed from dynamic reconfigure.

Setting MTU using launchtime GenICam GevSCPSPacketSize will not cause problem.

Maybe problem can be reproduced by service call GenICam setup at runtime

bmegli commented 1 year ago

The call would be:

rosservice call /camera/set_integer_feature_value "feature: 'GevSCPSPacketSize'
value: 9000"

Needs retesting scenario

bmegli commented 1 year ago

Reproducible (new way)

  1. From cold booted MotionCam3D and ROS PC
  2. Modify MTU on ROS PC OS side
sudo ifconfig enp60s0 mtu 9000
  1. Start ROS driver

  2. Wait until camera initializes

  3. Modify MTU on MotionCam3D ROS driver using service

rosservice call /camera/set_integer_feature_value "feature: 'GevSCPSPacketSize'
value: 9000"
  1. Request depth and raw image
bmegli commented 1 year ago

Workarounds

Set MTU at launchtime

Using GevSCPSPacketSize

This is not affected by bug.

Restart node

If getting corrupted data after service call changing MTU restarting node will fix the problem

Keep changing MTU

This worked with dynamic reconfigure, probably will also work with service

bmegli commented 1 year ago

Note: