Overview

The MocapApi API is the next generation programming interface of the NeuronDataReader (hereafter referred to as NDR). From the get-go, the goal has been to have an API with cross-platform compatibility (Win/Mac/Android/Ios/Linux, etc.), cross-engine access (Unity/unreal), and user-free updates. Today, MocapAPI supports C, C++, and C#, Windows, u3d and Unreal Engine.

The MocapAPI API receives outgoing socket data from AxisStudio, Pnlab and other software.

Naming rules and calling conventions

Naming rules

MocapApi has two particularly important data types: the interface data type, generally referred to in the naming convention of IMCpxxx and the handle data type, generally named as MCPXxxHandle_t. Other data types follow the Hungarian nomenclature.

The MCPXxxHandle_t handle type is the entity index of the object, responsible for organizing and managing data, but not granting data access. The IMCPXxx interface type is responsible for accessing data according to the MCPXxxHandle_t handle. Typically, the IMCPXxx type and the MCPXxxHandle_t type are used in conjunction.

Differences in Languages

Some differences in different languages+

From now on, the "Detailed Description of Types" section uses C++ as the main description language. Please refer to this section to convert structures to the corresponding language.

The following "class specification" uses C++ as the description language. Refer to this section to describe the conversion to the appropriate programming language.

The interface type

The interface type in the form of IMCpxxx cannot be created directly, but it can be obtained at any time as needed. The acquisition methods of C and C++ are similar, and the acquisition method of C# is acquired through static functions.

C and C++ acquisition methods

Since the interface type in the form of ICMPXxx cannot be created directly, it must be accessed through MCPGetGenericInterface. To achieve this, you must declare MCPGetGenericInterface.

Correspondingly, use the MCPGetProcessTable interface in C to obtain the corresponding type, and its implementation is as follows:

C# methods

Implementation in C# is easier. Simply call IMCpxxx.Xxx() directly.

Memory management

MocapApi follows the principle of whomever allocates memory needs to release it, that is, once the user calls the function CreateXxxxIMCpxxx, it needs to call the corresponding DestroyXxx function at the right time. The memory allocated by IMCPXxx and GetXxx functions is released by MocapApi itself.

Error handling

There are two kinds of errors in MocapApi. One is a function call error, such as an empty buffer or a parameter error. The other is an error during program execution, such as a communication error with AxisStudio or Pnlab. Each function in MocapApi will return a EMCPError error code, users can judge according to their actual situation and error. Errors during program execution will be introduced in the Event mechanism.

Logic Flow Chart

open_motion_api_EN

Detailed Description of types

IMCPApplication & MCPApplicationHandle_t

An Application corresponds to a broadcast output port in Axis Studio / Axis Lab. The Application encapsulates a collection of functions used to process data from Axis Studio / Axis Lab by calling PollApplicationNextEvent, polling the latest Axis Studio messages and the status information of the Application itself.

You may obtain it using the following IMCPApplication pointer:

&You need to use CreateApplication to create an Application entity

The reference code is as follows:

The following code can be used when an Application is no longer needed:

CreateApplication

Create an Application entity. When the entity is no longer needed, you need to manually call DestroyApplication.

ulApplicationHandle returns the handle of the Application entity.

DestroyApplication

After destroying an Application entity, the entity represented by ulApplicationHandle can no longer be used.

SetApplicationSettings

SetApplicationRenderSettings

OpenApplication

CloseApplication

GetApplicationRigidBodies

GetApplicationAvatars

The reference call code is as follows: (other similar function call mechanisms work in a similar fashion)

PollApplicationNextEvent

The size of each MCPEvent_t in pEvent needs to be assigned:

If you do not use cache mode parameters, then call the code in the following way:

GetApplicationSensorModules

GetApplicationTrackers

QueuedServerCommand

Send command to Server, it will not delete the command. If after calling this function, call DestroyCommand to delete the cmdHandle object, the Server will return the command execution result with no Event

IMCPAvatar & MCPAvatarHandle_t

The Avatar entity corresponds to the Avatar in AxisStudio, so it will only be available when connected to Axis Studio. The hierarchy of the Avatar can be obtained through GetAvatarRootJoint and the related functions of the Joint object.

You may use the following code to get the pointer of IMCPAvatar:

GetAvatarIndex

GetAvatarRootJoint

Joint is the skeleton node of Avatar, only when receiving BVH data.

GetAvatarJoints

GetAvatarJointByName

GetAvatarName

GetAvatarRigidBodies

RigidBody is a rigid body bound to the Avatar. This data is only available when receiving BVH data and when there is light mixing.

IMCPJoint && MCPJointHandle_t

Use the following code to get the pointer of IMCPJoint:

GetJointName

GetJointLocalRotaion

GetJointLocalRotaionByEuler

GetJointLocalTransformation

GetJointDefaultLocalTransformation

GetJointChild

GetJointBodyPart

JointBodyPart is a description of the Calc data and is only available when the Calc data is received.

GetJointSensorModule

SensorModule is the description of the Calc data and is only available when the Calc data is received.

IMCPRigidBody & MCPRigidBodyHandle_t

A pointer to the IMCPRigidBody can be obtained using the following reference code:

GetRigidBodyRotaion

GetRigidBodyTransformation

GetRigidBodieStatus

GetRigidBodyId

IMCPSensorModule & MCPSensorModuleHandle_t

A pointer to the IMCPSensorModule can be obtained using the following code:

GetSensorModulePosture

To get the Quaternion of Pose.

GetSensorModuleAngularVelocity

GetSensorModuleAcceleratedVelocity

GetSensorModuleId

GetSensorModuleCompassValue

GetSensorModuleTemperature

IMCPBodyPart & MCPBodyPartHandle_t

A pointer to the IMCPBodyPart can be obtained using the following code.

GetJointPosition

GetJointDisplacementSpeed

GetBodyPartPosture

IMCPTracker& MCPTrackerHandle_t

Tracker entity is corresponding to the Device in Alice/AHM, it is only available after connected to the Alice/AHM.

A pointer to IMCPTracker can be obtained using the following code.

GetDeviceCount

GetDeviceName

On the basis of obtaining DeviceCount, iterating from 0 to DeviceCount as serialNum to obtain DeviceName, and obtaining subsequent related data using DeviceName as key.

GetTrackerRotation

GetTrackerPosition

GetTrackerEulerAng

IMCPRenderSettings & MCPRenderSettingsHandle_t

A pointer to IMCPRenderSettings can be obtained using the following code.

You need to create a RenderSettings entity using CreateRenderSettings, the reference code is as follows:

When a RenderSettings is no longer needed the following code can be used:

You can also use GetPreDefRenderSettings to get some predefined RenderSettings entities, but not to destroy them using DestroyRenderSettings.

CreateRenderSettings

Create a RenderSettings entity and manually call DestroyRenderSettings when the entity is no longer needed. pRenderSettings returns a handle to the RenderSettings entity.

GetPreDefRenderSettings

SetUpVector

GetUpVector

SetFrontVector

GetFrontVector

SetCoordSystem

GetCoordSystem

SetRotatingDirection

GetRotatingDirection

SetUnit

GetUnit

DestroyRenderSettings

After destroying a RenderSettings entity, the entity represented by renderSettings is no longer available.

IMCPSettings && MCPSettingsHandle_t

Use the following code to get a pointer to IMCPSettings:

A Settings entity needs to be created using CreateSettings, with the following reference code:

Once the Settings entity is no longer needed, you need to destroy it. You can use the following reference code:

CreateSettings

Create a Settings entity and manually call DestroySettings when the entity is no longer needed pSettingsHandle returns a handle to the Settings entity.

DestroySettings

After destroying a Settings entity, the entity represented by ulSettingsSettings is no longer available.

SetSettingsUDP

SetSettingsUDPServer

When connect with UDP protocol, set the IP and Port of Server:

SetSettingsTCP

SetSettingsBvhRotation

SetSettingsBvhTransformation

SetSettingsBvhData

SetSettingsCalcData

IMCPCommand

MocapApi Command interface, it will be used to send command to the Server and receive the command reply from the Server. The command handle is MCPCommandHandle_t.

CreateCommand

  Create a command object based on the command flag.

SetCommandExtraFlags

Set additional command flags

For example: do StopCapture:

SetCommandExtraLong

Set command parameters

For example: do StartCapture:

GetCommandResultMessage

Gets the error message returned by the Server

GetCommandResultCode

Gets the error code returned by the Server

GetCommandProgress

Get the command execution progress returned by the Server

DestroyCommand

IMCPCalibrateMotionProgress

The calibration progress interface, the corresponding Handle is MCPCalibrateMotionProgressHandle_t. It can be obtained by IMCPCommand::GetCommandProgress(CommandProgress_CalibrateMotion, ...)

GetCalibrateMotionProgressCountOfSupportPoses

The number of calibration positions required for this calibration.

GetCalibrateMotionProgressNameOfSupportPose

Gets the calibration pose name for this calibration.

GetCalibrateMotionProgressStepOfPose

Gets the calibration phase of the specified calibration position.

GetCalibrateMotionProgressCountdownOfPose

Gets the countdown to the specified calibration position.

GetCalibrateMotionProgressProgressOfPose

Gets the calibration progress of the specified calibration position.

GetCalibrateMotionProgressStepOfCurrentPose

Gets the current calibration position and calibration phase

GetCalibrateMotionProgressCountdownOfCurrentPose

Gets the current calibration position and calibration countdown.

GetCalibrateMotionProgressProgressOfCurrentPose

Get the current calibration execution and calibration progress.

EMCPEventType

EMCPBvhRotation

EMCPBvhData

EMCPBvhTransformation

EMCPUpVector

EMCPFrontVector

EMCPCoordSystem

EMCPRotatingDirection

EMCPPreDefinedRenderSettings

EMCPUnit

EMCPReplay

EMCPCommand

EMCPCommandStopCatpureExtraFlag

EMCPCommandExtraLong

EMCPCommandProgress

EMCP_CalibrateMotionProgressStep

MCPEvent_t

Members:

MCPEventData_t

MCPEvent_Reserved_t

MCPEvent_MotionData_t

MCPEvent_SystemError_t

MCPEvent_SensorModuleData_t

MCPEvent_TrackerData_t

MCPEvent_CommandRespond_t