ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

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