Network topology discovery

Questions, comments, and issues that aren't related to a specific product
Post Reply
User avatar
jwhitman
Posts: 10
Joined: Tue Apr 07, 2020 9:45 am
Location: Pittsburgh, PA, USA
Contact:

Network topology discovery

Post by jwhitman » Wed Jun 03, 2020 12:54 pm

I am trying to see what, if any, ways there are to automatically discover the connectivity of the modules. This would make it so I wouldn't need to hand-code all the module serial numbers in the code.

For example, if I have a chain of them, and I can see them all on the network, is there any way to find out what order they are in the chain? In the C++ API for the Lookup class I see a "getConnectedGroupFromName" function but I suspect this is deprecated and don't know what it does since I mostly use the python API these days.

Similarly, if I have an ethernet switch where multiple modules are connected to it, can I find out which port each module is located on? I think this is less of a hebi problem and more of a switch problem-- I've been googling it and it seems to be possible if you have special software and a managed switch. But the small lightweight ones I like to use are unmanaged, and I'd like to do it via Python commands. Anyone have any thoughts on how I can do this? 
User avatar
curtis_layton
HEBI Official
Posts: 12
Joined: Fri Mar 27, 2020 6:55 pm
Location: Pittsburgh, PA
Contact:

Re: Network topology discovery

Post by curtis_layton » Wed Jun 03, 2020 1:04 pm

Hi,

There is not really an easy way to determine the order. The connected group functionality is specific to the snake modules - they have serial connections between each module in addition to the Ethernet connection. I know Dave has messed around with using the IMUs coupled with some amount of movement to work out the physical order of an arm. You could also wire up all of the M-Stop inputs separately to an IO Board and trigger them in order but this would make the wiring pretty messy. Maybe at least making a script that commands the LEDs to change color in a certain order would help.

- Curtis
User avatar
dave_rollinson
HEBI Official
Posts: 34
Joined: Tue Dec 31, 2019 11:58 am

Re: Network topology discovery

Post by dave_rollinson » Wed Jun 03, 2020 3:58 pm

Like Curtis said, we don't have a great general way of determining ID. The two methods we've tried to get a partial solution so far only work for actuators that are known to be chained together in series.

Using Kinematics + IMUs:
We've tested out using the IMUs to quickly identify actuators that are rigidly attached in series, like for an arm. That requires you to move the arm during a 'system ID' step. As long as each actuator is rigidly attached with no passive links in between, you can use the actuator's gyros and compare them to the actuator velocities and get a really solid map of topology, and a decent estimate of relative orientations.

Using Network Latency:
We've also looked at using the latency of the round-trip-time (RTT) of the communications to see if we can identify the connection order. This can be done by taking a log and looking at log.pcRxTime - log.pcTxTime. This kinda works, as each switch adds a small amount of delay (on the order of ~10 microseconds). But there's occasionally just enough jitter to have 1-2 modules switch order. I'd say this method is ~80% accurate, which has kept it from being a widely used method for us.

I can dig up and post some Matlab code that does these methods if you're interested.

-Dave
User avatar
florian_enner
HEBI Official
Posts: 14
Joined: Wed Mar 25, 2020 11:31 am
Location: Austria

Re: Network topology discovery

Post by florian_enner » Wed Jun 03, 2020 6:04 pm

I was busy making plots, so Dave beat me to it :evil:

1) Using Network Latency
I just did a quick test regarding the network latency on a setup with 36 daisy-chained modules. As Dave mentioned, the latency added by each switch is very small compared to the noise/jitter, so it's tough to get it to work reliably. The below plot is for ~25k data points on a (reasonably idle) Windows machine when using a direct network connection with static ip. Unfortunately, even at that many samples there are still a few swaps. You may be able to make it work, but it'd probably require a dedicated linux machine on a separate network with several minutes of samples in order to be reliable enough.
rtt_latency_sorting_25ksamples.png
rtt_latency_sorting_25ksamples.png (45.55 KiB) Viewed 538 times

Code: Select all

rtt = (log.pcRxTime - log.pcTxTime) * 1E3;
[~,idx] = sort(mean(rtt));
1
2
3
5 :evil:
4 :evil:
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23 :evil:
22 :evil:
24
25
26
27
28
29
30
31
33 :evil:
32 :evil:
34
35
36

2) Manual Setup
When I had to sort a large number of modules (e.g. the setup of 36) I wrote a little script that iterated through all modules, highlighted one of the device's LEDs, and asked for manual input about what index it should be. I then generated a sortable name, and used createGroupFromFamily() to create an alphabetically sorted group. I unfortunately don't have the full code handy, but below is a matlab snippet I use to visually verify the order.

Code: Select all

group = HebiLookup.newGroupFromFamily('robot');
leds = zeros(group.getNumModules, 3);
while true

    leds(:) = 0;
    for i = 1:group.getNumModules
        
        leds(i,:) = [1 0 0];
        group.send('led', leds);
        pause(0.05); % or pause and ask for the corresponding index
        
    end
    
end
In any case, encoding the connectivity via a naming convention would at least get rid of the painful step of hard coding serial numbers.
User avatar
jwhitman
Posts: 10
Joined: Tue Apr 07, 2020 9:45 am
Location: Pittsburgh, PA, USA
Contact:

Re: Network topology discovery

Post by jwhitman » Thu Jun 04, 2020 4:23 pm

Thanks for all the suggestions. I like the LED idea, I will think about how to adapt that for my custom hexapod. I'm switching around their order frequently so constantly crawling under it to find the serial numbers has become tiring.
Since I don't have a serial-chain robot, the IMU method would be hard to use. I am looking for methods that could help me determine the leg ordering on a hexapod, for instance, where each leg is plugged into a network switch (my case), or when all legs are in a big chain like Daisy.
The network latency thing seems interesting. I wonder if there's some way to make that more reliable?
It seems unintuitive to me that this should be such a difficult problem, so I am still optimistic that some creative solution exists.
What about the network switch? Any ideas on whether it is possible to get which port a device is plugged into on a switch? If I could do that, then I could always use port 1 for leg 1, etc. but I am not sure if its really feasible to do via a script with a cheap switch.
User avatar
dave_rollinson
HEBI Official
Posts: 34
Joined: Tue Dec 31, 2019 11:58 am

Re: Network topology discovery

Post by dave_rollinson » Mon Jun 08, 2020 12:37 pm

One more comment on the LEDs to identify actuators:

This situation is why two of the buttons in Scope on the Dashboard, and in the right-click menu for the Module List, are 'Red LED' and 'Clear LED'. You can select an actuator, and manually check the position on the robot, and then change its name, paste its SN, or whatever other method you use to make your groups.

Sorry if you know about this already. Just wanted to point this out, since having all the serial numbers / names in Scope at least keeps you from having to physically find the serial numbers on the actuators on the robot. But you do have to be close enough to see the LED color.

Hope that helps,
-Dave
User avatar
florian_enner
HEBI Official
Posts: 14
Joined: Wed Mar 25, 2020 11:31 am
Location: Austria

Re: Network topology discovery

Post by florian_enner » Mon Jun 08, 2020 5:29 pm

Setting up a dedicated machine, a dedicated network, and spamming messages for 5-10 minutes could probably make the network latency reliable enough. It's not usable for auto-configuration on boot, but if you only ever need that information after a physical hardware change, that may be good enough. You could always do a sanity check by comparing the IMUs against the determined configuration.

It's a shame that the switches technically already know about the network topology (see Spanning Tree Protocl), but so far I've unfortunately never found a good way to access that information.
Post Reply