Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi drone connection using SDK #85

Open
aarsht7 opened this issue Feb 1, 2023 · 5 comments
Open

Multi drone connection using SDK #85

aarsht7 opened this issue Feb 1, 2023 · 5 comments

Comments

@aarsht7
Copy link

aarsht7 commented Feb 1, 2023

How to reproduce the issue:

  • Be prepared with the at-least 2 drones of the same model (robomaster tt tello edu) with the updated firmware.
  • Put the drones in the wifi mode as mentioned in documentation and turn it on.
  • Connect the wifi of the computer with SDK to the 1st done's hot-spot/network and run this commands with the modification in the ssid and password of your local router/hot-spot. You can also know the drone's SN using this file. If you are unable to connect with the drone using SDK, set up the robomaster.config.LOCAL_IP_STR = "192.168.10.2" in the code, before creating the object of Drone() here. Do this for each drones you have.
  • Restart the drones in the network mode and connect the computer with SDK to the same local network as the drones.
  • After successful connection of the drones and knowing their SN numbers, I tried to run the basic code from the example from github modifying the SN. This is where I encountered the error and I tried to go around it but I encountered the another error. The detailed error msg and the things I tried is mentioned in the next section.

Things you might notice during the above procedure.

  • You might not have any restart of the drone as mentioned in the documentation 3.2 -> 2 -> point-3.
  • In the case your drone does not restart and code is executed successfully, you can turn off the drone, switch it to the networking mode using the switch on the side of the led matrix and turn it back again.
  • You will notice the propellers are rotating at slower speed when you start the drone in the network mode after successfully execution of the above code. This means the drone is successfully connected to the local network. If you are not working on the drone immediately and debugging the code, you can tilt the drone more than ~45 degrees on any side and propellers will stop rotating.

THE ERROR

At very first execution of this example from github, I got the following error

Traceback (most recent call last):
 File "test-2.py", line 17, in <module>
   multi_drone.initialize(robot_num=2)
 File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/multi_robot.py", line 272, in initialize
   self._robot_host_list = self._client.scan_multi_robot(robot_num)
 File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 320, in scan_multi_robot
   return self._conn.scan_multi_robot(num)
 File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 266, in scan_multi_robot
   robot_host_list = self._scan_host(num)
 File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 232, in _scan_host
   subnets, address = get_subnets()
 File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 106, in get_subnets
   broadcast = ipinfo['broadcast']
KeyError: 'broadcast'

After having good view on the code downloaded from the pip install and the code on this github repo, I find its not the same. For starter, you can go to the PyPi robomaster download latest whl and check the line 106 in multi_robomaster/tool.py and same file multi_robomaster/tool.py line 103 on github. You notice the error producing line broadcast = ipinfo['broadcast'] is not present on the github version.

After some printing and debugging and chatting with the dev team of dji @dji-dev , I realise it was giving the error because of the multiple physical and virtual network cards (self, LAN, wifi, docker and few more) available on the system. After that I tried to iterate over only wifi using the wifi adapter name in this for loop. But I get the following Error

[Errno 22] Invalid argument
  File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 258, in _scan_host
    self._sock.sendto(b'command', (ip, self.local_port))
  File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 271, in scan_multi_robot
    robot_host_list = self._scan_host(num)
  File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/tool.py", line 325, in scan_multi_robot
    return self._conn.scan_multi_robot(num)
  File "/home/aarsh/.local/lib/python3.8/site-packages/multi_robomaster/multi_robot.py", line 272, in initialize
    self._robot_host_list = self._client.scan_multi_robot(robot_num)
  File "/home/aarsh/DJI/tt/SDK/test-2.py", line 18, in <module>
    multi_drone.initialize(robot_num=2)
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
OSError: [Errno 22] Invalid argument

Here I am stuck and have no idea what to try next.
Any help would be appreciated.
Thanks.

@hummelslei
Copy link

hummelslei commented Mar 30, 2023

def __init__(self, local_ip=conn.get_local_ip(), local_port=8889):
please modify local_ip to be equal to your actual local IP address. For example 192.168.10.2

@aarsht7
Copy link
Author

aarsht7 commented Mar 30, 2023

Thank you @hummelslei . I will give it a try and update you about it by tomorrow. 👍🏻

@aarsht7
Copy link
Author

aarsht7 commented Mar 31, 2023

Hello @hummelslei , The solution did not worked for me. I am still getting the same error.

@hummelslei
Copy link

The solution recommended by our R&D is as follows. Please modify it according to the recommended method.
Modify demo
image
Modify library:
image

@aarsht7
Copy link
Author

aarsht7 commented Mar 31, 2023

Hello @hummelslei
This works BUT I had to make one more change in the code. I can make a pull request to this repo with all the changes I made to work it without any problem.
NOTE : this changes will not affect already working codes. the changes will only trigger when it is required. I can also document for the website (in English)
Once again Thanks Hummels 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants