API SetEMotor not work



I use C# sample in DobotClientDemo2.0 as practice. I want to control conveyor belt and I notice there is no SetEMoter function, so I add one.

Function SetEmotor added in DobotDll.cs
[DllImport(“DobotDll.dll”, EntryPoint = “SetEMotor”, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetEMotor(ref EMotor emotor, bool isQueued, ref UInt64 queuedCmdIndex);

Struct EMotor added in DobotDllType.cs
public struct EMotor {
public byte index;
public byte isEnabled;
public UInt32 speed;

Execute SetMotor
private int setmotor(bool isEnabled, UInt32 speed, bool isQueued)
EMotor emotor;
emotor.index = 0;
emotor.isEnabled = 1;
emotor.speed = speed;
UInt64 cmdIndex = 0;
int ret = DobotDll.SetEMotor(ref emotor, isQueued, ref cmdIndex);
return ret;

Return 0 but nothing happened.

I tried SetEMotor in DobotStudio script and it works fine.


I am experiencing the same or very similar issue with Python. Would greatly appreciate if anybody could shed any light, why it works in DobotStudio and not from outside.


Dear DOBOT team, please take a look into these messages in case you could please shed some light. Sincerely.


Using ROS and C++ encounter the same problem. The convey belt is powered up, but does not move.


Did you manage to solve the problem already?


Hi guys :slight_smile:
I made the belt working in c#. This worked for me.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct EMotor
    public byte index;
    public byte isEnabled;
    public Int32 speed;


Did anyone managed to make it work? Trying in Python, also receiving a DobotCommunicate_NoError, the conveyor is making some fade noise (similar to being powered up) but does not move.


OK, indeed, there is a mistake in the DobotDll.py, in the struct EMotor, the speed is defined as a float.
Similar to what ratfrom precised, it should be changed from:
(“speed”, c_float)
(“speed”, c_int32)

Works fine now.