Streaming Motion Buffer Management sample application.
This sample code is built for the RMP but the concepts should apply to all RapidSoftware Applications. It gives a very simple initialization of an RMP MotionController. It only prints out errors rather than handling them.
This application assumes that you will be generating points which have times of exactly 1 sample duration. If you want to generate points of size X samples, be sure to divide initial Sample Rate Deduction by X.
- Precondition
- This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
- Warning
- This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires.
- Copyright
- Copyright © 1998-2019 by Robotic Systems Integration, Inc. All rights reserved. This software contains proprietary and confidential information of Robotic Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth in the license agreement under which this software is supplied, disclosure, reproduction, or use with controls other than those provided by RSI or suppliers for RSI is strictly prohibited without the prior express written consent of Robotic Systems Integration.
#include "rsi.h"
#include <process.h>
using namespace RSI::RapidCode;
const int AXIS_COUNT = 2;
const int DESIRED_POINTS = 50;
const int SYNC_PERIOD = 10;
int32 lastSample = 0;
#pragma region Fixed Size Implementation
const int POINT_BLOCK_COUNT = 10;
int32 extraPointsSentToEvenOutBlock = 0;
int32 AdjustPointsNeededToBlockCount(int32 initialCount)
{
int32 calculatedCount = 0;
int32 adjustedInitialCount = initialCount - extraPointsSentToEvenOutBlock;
while ((adjustedInitialCount > 0) && (adjustedInitialCount > calculatedCount))
{
calculatedCount += POINT_BLOCK_COUNT;
}
extraPointsSentToEvenOutBlock += calculatedCount - initialCount;
return calculatedCount;
}
#pragma endregion
volatile int _continueMonitoring = true;
void monitoringThread(void* tmp)
{
while (_continueMonitoring)
{
int32 pointsNeeded = sampleRecieved - lastSample;
pointsNeeded = AdjustPointsNeededToBlockCount(pointsNeeded);
lastSample = sampleRecieved;
}
}
{
{
}
}
void streamingMotionBufferManagementMain()
{
checkErrors(controller);
try
{
checkErrors(controller);
_beginthread(monitoringThread, 0, controller);
bool exitCondition = false;
while (!exitCondition)
{
}
}
{
printf(
"\n%s\n", err.
text);
}
_continueMonitoring = false;
}