S4ProgramVariableRead returns -515 [WebWare SDK]
zcrosscorr.m is a matlab file I compiled into c and am using in an application that communicates with the ABB robot via the Webware SDK. In one of my default class constructors I was instantiating the zcrosscorr lib files using zcrosscorrInitialize();. When I did this S4ProgramVariableRead returned -515 later in my application. However, when I moved zcrosscorrInitialize() to a seperate function call and called it after the helper wrapper class (for the Webware controls) was instantiated the S4ProgramVariableRead returned 0 and worked. Why is this occuring? Has anyone seen this occur before. My application is written in Visual Studio 6.0 and the matlab file was compiled with the Matlab Compiler 4.0. Any help would be very much appreciated. Thanks.
Comments
-
Could you please provide us with some sample code? Atleast of the VS6 code that calls the S4ProgramVariableRead method.
______________________________
Anders Dannberg
ABB Automation Technologies
Support Engineer0 -
The following is my class constructor and destructor in which I was initializing the zcrosscorr matlab routines.
//code
CbinCorrelation::CbinCorrelation() {
disparityMax = NULL;
disparityMin = NULL;
imgRegionR.imgData = NULL;
imgRegionL.imgData = NULL;
initialized = 1;//Temp display windows
cvNamedWindow("ContourImageRight", 0);
cvNamedWindow("ContourImageLeft", 0);
cvNamedWindow("Initial Right", 0);
cvNamedWindow("Initial Left", 0);/* Call the mclInitializeApplication routine. Make sure that the application
* was initialized properly by checking the return status. This initialization
* has to be done before calling any MATLAB API's or MATLAB Compiler generated
* shared library functions. */
mclInitializeApplication(NULL, 0);if (!zcrosscorrInitialize()) {
fprintf(stderr, "Unable to initialize Zcrosscorr library!");
initialized = 0;
}
}CbinCorrelation::~CbinCorrelation() {
//Free used memory
if (disparityMax != NULL) {
delete [] disparityMin;
delete [] disparityMax;
}
if (imgRegionR.imgData != NULL) {
delete [] imgRegionR.imgData[0];
delete [] imgRegionR.imgData;
imgRegionR.imgData = NULL;
}
if (imgRegionL.imgData != NULL) {
delete [] imgRegionL.imgData[0];
delete [] imgRegionL.imgData;
imgRegionL.imgData = NULL;
}if (initialized) {
zcrosscorrTerminate();
}mclTerminateApplication(); //terminate all matlab libs
//Temp display window cleanup
cvDestroyWindow("ContourImageRight");
cvDestroyWindow("ContourImageLeft");
cvDestroyWindow("Initial Right");
cvDestroyWindow("Initial Left");
}//end code
CRobot::Move is called from a dialog when a button press is registered and after the the needed parameters have been calculated. S4VariableRead is called within CRobot::ProgramVariableRead which is called by CRobot::Move. This method is also provided.
//code
double CRobot::Move(float xTail, float yTail, float xCentroid, float yCentroid, int breast)
{
double theta;
ProgramNumVarWrite("breast",(float)breast);theta = atan2((yTail - yCentroid), (xTail - xCentroid));
if(ProgramVariableRead("currentPos",m_robtarget.m_lpDispatch))
{
m_robtarget.SetPos(0, xTail-95*cos(theta)); //-95*cos(theta)-20*sin(theta)
m_robtarget.SetPos(1, yTail-95*sin(theta)); //-95*sin(theta)+20*cos(theta)
}ProgramVariableWrite("currentPos", m_robtarget.m_lpDispatch);
theta = atan2((yCentroid - yTail), (xTail - xCentroid));
theta = (theta * 180)/PI;
ProgramNumVarWrite("thethaChange",(float)theta);
RunProgramOnce();return theta;
}
bool CRobot::ProgramVariableRead(LPCTSTR varname, LPDISPATCH value)
{
short status = m_helper->S4ProgramVariableRead(varname, 0, value);
if(status)
{
CString ErrorMsg;
ErrorMsg.Format("Error reading '%s', status = %i",varname,status);
AfxMessageBox(ErrorMsg,MB_OK | MB_ICONSTOP);
return false;
}
return true;
}//end code
When I changed the class constructor and destructor for CbinCorrelation to not include zcrosscorrInitialize and zcrosscorrTerminate, and instead made seperate function calls within CbinCorrelation so I could call these methods from OnInitDialog it allowed S4ProgramVariableRead to work. However, leaving these initialization calls inside the constructor for my class causes the S4ProgramVariableRead to fail and return -515.
Sorry, for not initially including my code. If more specifics are needed just let me know. Thanks for your help.
0 -
Hi,
I want to know how you get the eventhandler generated after adding a variable(num in this case) to the subscribtionlist. What's the next step after that.....
I working in C#.
0 -
Hello,
If you want to capture num variable event changes using the Helper control, you could use (VB.NET):Private Sub AxHelper1_NumVariableChanged(ByVal sender As Object, ByVal e As AxRimbaseLib._DHelperEvents_NumVariableChangedEvent) Handles AxHelper1.NumVariableChanged
MsgBox("Num Variable change event fired")
End SubDoing the same thing for string variables for instance, you would want to use HelperObject_StringVariableChanged event.
______________________________
AndersD38401,5584375
Anders Dannberg
ABB Automation Technologies
Support Engineer0 -
Hey Anders,
What I'm looking for is a method definition for C#.
0 -
Here's a C# project that with only one event: NumVariableChanged to demonstrate how to use this event in C# code.
______________________________
Anders Dannberg
ABB Automation Technologies
Support Engineer0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings