Asked

C# Question About Invoking A Custom Action

Trying to call

EZBManager.MovementManager.GoCustom("Bow");

from a button click to invoke the canned Bow action.  Does nothing.  What am I missing?



Related Hardware (view all EZB hardware)
JD Humanoid by EZ-Robot
JD humanoid robot kit - WiFi-enabled, 16 DOF with metal-gear servos; easy, fun, educational, available from the EZ-Robot online store.
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

Author Avatar
PRO
Synthiam
#1  

Here you go - you have to bind to the movement event and retrieve the name of the custom action.


using System;
using System.Windows.Forms;
using ARC;

namespace Custom_Movement_Example {

  public partial class MainForm : ARC.UCForms.FormPluginMaster {

    readonly string MOVEMENT_JUMP_ID = "Jump";

    public MainForm() {

      InitializeComponent();

      // show a config button in the title bar. Set this to false if you do not have a config form.
      ConfigButton = true;

      // Bind to the movement event for every movement that is specified this will raise
      EZBManager.MovementManager.OnMovement2 += MovementManager_OnMovement2;
    }

    private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {

      // Unbind from the movement event when the form is going away
      EZBManager.MovementManager.OnMovement2 += MovementManager_OnMovement2;
    }

    private void MovementManager_OnMovement2(MovementManager.MovementDirectionEnum direction, byte speedLeft, byte speedRight) {

      if (direction == MovementManager.MovementDirectionEnum.Custom && EZBManager.MovementManager.GetCustomMovementId == MOVEMENT_JUMP_ID) {

        // Handle the code here for the custom movement type
      }
    }

    private void btnCustomMovement_Click(object sender, EventArgs e) {

      // This will execute the custom movement action

      EZBManager.MovementManager.GoCustom(MOVEMENT_JUMP_ID);
    }
  }
}