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_robot connection when connected to multiple networks #105

Open
MrCampbellDuchess opened this issue Jan 8, 2025 · 4 comments
Open

Comments

@MrCampbellDuchess
Copy link

I am attempting to connect to two robots at the same time using multi_robot. These are EP-model robots.

from robomaster import config

def group_task(robot_group):
    x = 0.3
    y = 0.3
    z = 90

    # 前进 0.3米
    robot_group.chassis.move(-x, 0, 0, 2, 180).wait_for_completed()

    # 后退 0.3米
    robot_group.chassis.move(x, 0, 0, 2, 180).wait_for_completed()

    # 左移 0.3米
    robot_group.chassis.move(0, -y, 0, 2, 180).wait_for_completed()

    # 右移 0.3米
    robot_group.chassis.move(0, y, 0, 2, 180).wait_for_completed()

    # 左转 90度
    robot_group.chassis.move(0, 0, z, 2, 180).wait_for_completed()

    # 右转 90度
    robot_group.chassis.move(0, 0, -z, 2, 180).wait_for_completed()


def group_task1(robot_group):

    # 前进 0.3米
    robot_group.chassis.move(0.3, 0, 0, 2, 180).wait_for_completed()


if __name__ == '__main__':
    #get robot sn by run the exmaples of /15_multi_robot/multi_ep/01_scan_robot_sn.py
    robots_sn_list = ['3JKDH6U001P03L', '3JKDH6U00162BX']
    config.LOCAL_IP_STR="192.168.0.189"
    multi_robots = multi_robot.MultiEP()
    multi_robots.initialize()
    number = multi_robots.number_id_by_sn([0, robots_sn_list[0]], [1, robots_sn_list[1]])
    print("The number of robot is: {0}".format(number))
    robot_group = multi_robots.build_group([0, 1])
    robot_group1 = multi_robots.build_group([0])
    multi_robots.run([robot_group, group_task])
    multi_robots.run([robot_group1, group_task1])
    print("Game over")
    multi_robots.close()

I can connect to each robot individually, but in order to connect I have to define config.ROBOT_IP_STR when I do that.

As you can see from the above code, I have added config.LOCAL_IP_STR to force connection via Ethernet rather than this devices WiFi as I am in an education setting and cannot change wifi networks.

The SN in the code above is the SN of my robots, confirmed by checking using the single robot connection method and get_sn().

Can robots by identified by IP instead of by SN?

Does the scanning procedure to find robots by SN utilize specific ports? My concern is the Windows Firewall is blocking outgoing scanning attempts.

@brunoga
Copy link

brunoga commented Jan 10, 2025

This is a guess as I never used this (also, I am pretty sure this repository is dead and no one form DJI is working with the Robomaster SDK anymore) but: The robot itself is connected through WiFi. The way the code works is by listening for broadcasts and it is likely (although not necessary required) that the ethernet network you are connected to is separate from the WiFi network in this respect so it can not see the robot's broadcast.

@MrCampbellDuchess
Copy link
Author

You are correct about the network. I have a separate network for just the robots and the laptops controlling them, with the laptops using ethernet to access it. I can assign a specific LOCAL_IP_STR and ROBOT_IP_STR to allow connections but I believe it's the scanning functionality that doesn't work.

Looking at the back-end, it looks like the scanning function picks a random port number and scans using that, which is going to play a mess with any firewalls...oh well.

@brunoga
Copy link

brunoga commented Jan 10, 2025

Not really. The Robomaster EP sends broadcasts to port 40927 only. To find a robot this is the only port you need to open. Whenever you see a random port being picked, this is a LOCAL random port which is completely irrelevant for a firewall. AFAIK, the robot never starts a connection to the controlling device.

@brunoga
Copy link

brunoga commented Jan 10, 2025

Oh, of course you also need to make sure that broadcast packets will be routed from the wifi network to the wired network.

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