Tutorial 3-8: Setting parameters

Parameters are systemwide settings that are typically configured during initialization and sometimes also changed during operation. Each parameter is explained in detail in Parameters.

When the engine is started, the default parameter values are loaded. Changing a parameter setting usually involves calling the function to retrieve the current values of a set of parameters, modifying some values, and then writing the parameters back to the engine.

The following code obtains the current values of the common parameters, changes a few values, and then writes back the parameters to the engine.

//Read the current values of parameters
err = wmxlib_cm.config->GetParam(&param);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to get parameters. Error=%d (%s)\n", err, errString);
    goto exit;
}

param.feedbackParam[0].inPosWidth = 2000; //Set the "in position width" parameter of axis 0
param.feedbackParam[1].inPosWidth = 3000; //Set the "in position width" parameter of axis 1

//Write the updated values of parameters
err = wmxlib_cm.config->SetParam(&param);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to set parameters. Error=%d (%s)\n", err, errString);
    goto exit;
}

Note that if you are using WMX3 Console to check the values of the parameters from the “Config” window, the “Refresh” button must be pressed to read the updated parameter settings from the engine.