GT-RAIL / keyboardteleopjs

Keyboard Teleoperation via Twist Messages
http://robotwebtools.org/
Other
20 stars 16 forks source link

Multi-robots support #11

Open rk4an opened 10 years ago

rk4an commented 10 years ago

Hi,

When I try to used the keyboard-teleop with multi-robots I found this:

When I choose a second robot I recreate an new Teleop object for this robot (with a new topic name of course) . And if I want to remove the old Teleop object I need to clean old "eventListener" still remaining in the body.

Currently if I want to used removeListener() function to cleanup, I need a reference to this function rigth? So I think we need to edit the lib?

So did you think that it possible to have a function for this? :)

Regards,

rctoris commented 10 years ago

As it currently stands there is no direct reference to the function(s), they are created on-the-fly during the event creation: https://github.com/WPI-RAIL/keyboardteleopjs/blob/stable/src/teleop/Teleop.js#L103-L108 This of course could be changed.

What happens if you "delete" the object (e.g., let it go out of scope so it is garbage collected), does the event listener stay?

rk4an commented 10 years ago

If I do a global var teleop and then recreate a new teleop by overwritten this var, the event listener stay, so if I press a key I write in 2 topics and my 2 robots moves together (garbage collector not work is this case?)

Currently I do a small hack with jQuery, I add event listener on body with ".on()" function, and call ".off()" function to remove all listener.

Maybe a idea is to have two functions on the teleop (.enable and .disable with add/remove event listener)