Tutorial 2: System Initialization

This part covers the following.

  1. Initialization of the control target using the WMX3 Robot module.

1. Sample Code

InitWMX

To use the WMX3 robot module, a device (WMX3Api dev) provided by WMX3Api must be created. You can activate the device by calling the CreateDevice function. For detailed usage, please refer to the WMX3 User Manual.

The following is an example of initialization using the device class (WMX3Api).

int InitWMX(wmx3Api::WMX3Api& dev)
{
    int ret = 0;
    ret = dev.CreateDevice("C:\Program Files\SoftServo\WMX3\", wmx3Api::DeviceType::DeviceTypeNormal, INFINITE);

    ret = dev.SetDeviceName("Robot");
    ret = dev.SetWatchdog(60 * 60 * 1000);
    ret = dev.StartCommunication();

    return ret;
}

InitRobotSystem

To operate a robot with WMX3, the following three classes are basically required.

wmx3Api::WMX3Api dev;
wmx3Api::RobotMotion robot(&dev);
wmx3Api::RobotMotionParam robotMotionParam;

[1] WMX3Api : Device class

[2] RobotMotion : Robot class

[3] RobotMotionParam : Robot motion parameters

  • RobotMotion is a core class related to robots. All actions from system initialization to status update, motion, and stop can be performed through this class. The RobotMotion class, like other module classes in WMX3, requires a device (WMX3Api).

  • RobotMotionParam is a class that stores various parameters necessary for designing robot motion. You can set it directly or read it from a settings file (xml).

The following is an example of initialization for operating a robot.

int InitRobotSystem(wmx3Api::RobotMotion& robot, wmx3Api::RobotMotionParam& robotMotionParam)
{
    int ret = 0;
    TCHAR wmxParameterFile[] = _T("wmx_parameter_MZ07L.xml");
    TCHAR robotParameterFile[] = _T("robotParamXML_MZ07L.xml");

    ret = robot.IsDeviceValid();
    ret = robot.mCoreMotion.config->ImportAndSetAll(wmxParameterFile);
    ret = robot.mRobotConfig.ImportParamXML(robotParameterFile, robotMotionParam);
    ret = robot.mKinematics.SetRobotParam(robotMotionParam.robotParam);

    return ret;
}

  • wmx_parameter_MZ07L.xml is the settings file for WMX3. Information about sensors and actuators, such as the electronic gear ratio of the servo connected to WMX3, is recorded.

  • robotParamXML_MZ07L.xml is the robot’s settings file. The settings file (xml) is parsed into RobotMotionParam and stored in the second argument of the ImportParamXML function.

  • wmx3::RobotMotion can receive a device (wmx3Api::WMX3Api) as an argument. If there is no argument, it creates a device internally, which is called the Self Device state.

  • The SetRobotParam function performs data initialization of the WMX3 Engine for the robot.

2. Program Execution Result

After starting the WMX3 Engine, please run the example program.

If all procedures are performed normally, “End of program” will be output to the console.

../_images/ROBOT_OPTION_DOC_TUTORIAL_ROBOT_SYSTEM_INITIALIZATION_END_OF_PROGRAM.png