Adding a new key function to the OpenROV


#1

After months of work I finally made the OpenROV get the ability to move automatically. But I find it necessary to add a key function from the laptop to disactivate the original-code and switch it to the mode of autonomus moving. Any methods to add a new key function to send the order to the ROV from laptop?
I am completely new to Socket/io or stuff like that.


#2

A months ago the OpenROV enginner sent me this flow chart on how messeages travel, but I literally did not find the deps.cockpit.on() and the rovpilot-wire in the original code.


#3

For a good example of how to bind commands to keys, take a look at the browser side of the rovpilot-wire plugin in https://github.com/OpenROV/openrov-cockpit/blob/master/src/plugins/rovpilot-wire/public/js/rovpilot-wire.js#L16

  ROVpilotWire.prototype.inputDefaults = function inputDefaults() {
    var self = this;
    return [
      // Toggle heading hold
      {
        name: 'rovPilot.toggleHeadingHold',
        description: 'Toggles the heading hold on/off',
        defaults: { keyboard: 'm' },
        down: function () {
          self.cockpit.rov.emit('plugin.rovpilot.headingHold.toggle');
        }
      },

      // Toggle depth hold
      {
        name: 'rovPilot.toggleDepthHold',
        description: 'Toggles the depth hold on/off',
        defaults: { keyboard: 'n' },
        down: function () {
          self.cockpit.rov.emit('plugin.rovpilot.depthHold.toggle');
        }
      }
    ]
  }

If you wanted to add a new key which triggers a command to enter autonomous mode, you could add the following to the public interface for your code:

  AutonomyPlugin.prototype.inputDefaults = function inputDefaults() 
  {
    var self = this;
    return [
      // Toggle autonomous mode
      {
        name: 'autonomyPlugin.toggleAutonomousMode',
        description: 'Toggles Autonomous Mode on/off',
        defaults: { keyboard: '<desired key>' },
        down: function () 
        {
          self.cockpit.rov.emit('plugin.autonomyPlugin.engaged.toggle');
        }
      }
    ]
  }

#4

Thanks so much. One more stuff I am confused,

What’s the difference between the code you have mentioned and this code, it seems that they bind the command