dji-sdk / RoboMaster-SDK

DJI RoboMaster Python SDK and Sample Code for RoboMaster EP.
Apache License 2.0
311 stars 142 forks source link

Catch EADDRINUSE in scan_robot_ip on bind #43

Closed janblumenkamp closed 2 years ago

janblumenkamp commented 3 years ago

I am currently working on a very simple ROS2 driver for the RoboMaster. I don't want to use the MultiRobot API, instead, I want to start multiple processes that connect to each robot with the single robot API (it makes more sense to have an independent ROS node for each robot). This works if I start the nodes independently, but if they are launched at the same time in a launch file, only one of the processes will be able to send the UDP broadcast and the other ones will throw the EADDRINUSE exception. In this PR, I catch this specific error code (raise all other ones), therefore if multiple processes attempt an IP scan at the same time, it will just wait for the timeout instead of failing immediately.