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 JD Humanoid

ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

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);
    }
  }
}