19#include "SampleAppsHelper.h"
22#pragma region GantryDeclares
27int linearAxisNumber = 0;
30int defaultEncoderNumerator = 0;
31int defaultEncoderDenominator = 0;
32int gantryEncoderNumerator = 1;
33int gantryEncoderDenominator = 2;
35double x1PrimaryCoeff = 1.0;
36double x2PrimaryCoeff = 1.0;
37double x1SecondaryCoeff = 1.0;
38double x2SecondaryCoeff = -1.0;
39double defaultPrimaryCoeff = 1.0;
40double defaultSecondaryCoeff = 0.0;
42uint64_t x1EncoderAddress;
43uint64_t x2EncoderAddress;
44uint64_t x1FilterPrimaryPointerAddress;
45uint64_t x1FilterSecondaryPointerAddress;
46uint64_t x2FilterPrimaryPointerAddress;
47uint64_t x2FilterSecondaryPointerAddress;
48uint64_t x1FilterPrimaryCoefficientAddress;
49uint64_t x1FilterSecondaryCoefficientAddress;
50uint64_t x2FilterPrimaryCoefficientAddress;
51uint64_t x2FilterSecondaryCoefficientAddress;
52uint64_t x1AxisLinkAddress;
53uint64_t x2AxisLinkAddress;
56#pragma region GantryMethods
57void ReadAddressesFromMotionController()
73void SetupEncoderMixing(
bool enableGantry)
102void SetupFilterMixing(
bool enableGantry)
107 mc->MemorySet(x1FilterPrimaryPointerAddress, mc->FirmwareAddressGet(x1AxisLinkAddress));
108 mc->MemorySet(x1FilterSecondaryPointerAddress, mc->FirmwareAddressGet(x2AxisLinkAddress));
110 mc->MemorySet(x2FilterPrimaryPointerAddress, mc->FirmwareAddressGet(x1AxisLinkAddress));
111 mc->MemorySet(x2FilterSecondaryPointerAddress, mc->FirmwareAddressGet(x2AxisLinkAddress));
114 mc->MemoryDoubleSet(x1FilterPrimaryCoefficientAddress, x1PrimaryCoeff);
115 mc->MemoryDoubleSet(x1FilterSecondaryCoefficientAddress, x1SecondaryCoeff);
117 mc->MemoryDoubleSet(x2FilterPrimaryCoefficientAddress, x2PrimaryCoeff);
118 mc->MemoryDoubleSet(x2FilterSecondaryCoefficientAddress, x2SecondaryCoeff);
123 mc->MemorySet(x1FilterPrimaryPointerAddress, mc->FirmwareAddressGet(x1AxisLinkAddress));
124 mc->MemorySet(x1FilterSecondaryPointerAddress, mc->FirmwareAddressGet(x1AxisLinkAddress));
126 mc->MemorySet(x2FilterPrimaryPointerAddress, mc->FirmwareAddressGet(x2AxisLinkAddress));
127 mc->MemorySet(x2FilterSecondaryPointerAddress, mc->FirmwareAddressGet(x2AxisLinkAddress));
129 mc->MemoryDoubleSet(x1FilterPrimaryCoefficientAddress, defaultPrimaryCoeff);
130 mc->MemoryDoubleSet(x1FilterSecondaryCoefficientAddress, defaultSecondaryCoeff);
132 mc->MemoryDoubleSet(x2FilterPrimaryCoefficientAddress, defaultPrimaryCoeff);
133 mc->MemoryDoubleSet(x2FilterSecondaryCoefficientAddress, defaultSecondaryCoeff);
136void GantryEnable(
bool enable)
138 ReadAddressesFromMotionController();
141 SetupEncoderMixing(enable);
142 SetupFilterMixing(enable);
143 linearAxis->ClearFaults();
144 linearAxis->AmpEnableSet(
true);
145 yawAxis->ClearFaults();
146 yawAxis->AmpEnableSet(
true);
158 linearAxis = mc->AxisGet(linearAxisNumber);
161 yawAxis = mc->AxisGet(yawAxisNumber);
165 ReadAddressesFromMotionController();
uint64_t AddressGet(RSIAxisAddressType addressType)
Get the an address for some location on the Axis.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
@ RSIAxisGantryTypeSUBTRACT
@ RSIAxisAddressTypeAXIS_LINK
Axis Link for Gantry use.
@ RSIAxisAddressTypeENCODER_PRIMARY
Primary Encoder position.
@ RSIAxisAddressTypeFILTER_SECONDARY_POINTER
Filter Secondary Pointer for Gantry use.
@ RSIAxisAddressTypeFILTER_SECONDARY_COEFF
Filter Secondary Coefficient for Gantry use.
@ RSIAxisAddressTypeFILTER_PRIMARY_COEFF
Filter Primary Coefficient for Gantry use.
@ RSIAxisAddressTypeFILTER_PRIMARY_POINTER
Filter Primary Pointer for Gantry use.
@ RSIAxisPositionInputSECOND
Secondary encoder.
@ RSIAxisPositionInputFIRST
Primary encoder.
@ RSIMotorFeedbackPRIMARY
Primary encoder.
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...