CP Mode issue with MATLAB


#1

Hello everybody

I have to use the CP mode with Matlab to move the dobot magician.
I want to use the function 'SetCPCmd" for this. But I have a problem when I want to create a strucutre with ‘tagCPCmd’. This is my code :

%load DobotDll
if ~libisloaded(‘DobotDll’)
[notfound, warnings]=loadlibrary(‘DobotDll.dll’,‘DobotDll.h’);
end
%libfunctionsview DobotDll

%create size 128 charArrays
ch=blanks(128);

%create pointer piont to charArrays
str1= libpointer(‘cstring’,ch);

%search the magician device res1:device number res2:device address
[res1,res2]=calllib(‘DobotDll’,‘SearchDobot’,str1,128);

%create pointer piont to device address
str2= libpointer(‘cstring’,res2);
%contect device res3:contect result 0:success 1:error 2:timeout
[res3,res4]=calllib(‘DobotDll’,‘ConnectDobot’,str2, 115200);

cp.cpMode=1;
cp.x=150180/3.14;
cp.y=100
180/3.14;
cp.z=147*180/3.14;
cp.velocity=150;

%create c type struct
Cpstruct=libstruct(‘tagCPCmd’,cp);

%create ptp pointer
ptpstructptr=libpointer(‘tagCPCmdPtr’,Cpstruct);
queue_index_ptr=libpointer(‘uint64Ptr’,queue_index);

%send ptp cmd
calllib(‘DobotDll’,‘SetCPCmd’,ptpstructptr,true,queue_index_ptr);

The problem is at the line : ‘Cpstruct=libstruct(‘tagCPCmd’,cp);’

My error is :

Error using feval
Undefined function or variable ‘lib.tagCPCmd’.

Error in libstruct (line 16)
ptr=feval([‘lib.’ structtype],initialvalue);

Error in Untitled (line 28)
Cpstruct=libstruct(‘tagCPCmd’,cp);

My library is in the same folder. The “libstruct” with “tagPTPCmd” works therefore it works with the PTP Mode. So, I don’t understand why I can’t reach this structure (tagCPCmd) and why it is “Undefined”.

I know it is not very clear but I did my best to explain.

Thank you !