Error Using simSetShapeColor

Typically: "How do I... ", "How can I... " questions
Post Reply
DavideIng
Posts: 39
Joined: 21 Sep 2017, 17:27

Error Using simSetShapeColor

Post by DavideIng » 19 Oct 2017, 12:08

Hello,
I have a problem with simSetShapeColor arguments.
The following is the code to get a color string from Matlab:

Code: Select all

if (sim_call_type==sim_childscriptcall_actuation) then
GotString = simGetStringSignal('ChangeColor')
UnpackedString = simUnpackFloatTable(GotString)
simSetShapeColor(handlePlane,nil,0,UnpackedString)
end
Vrep return this error:

Lua runtime error: [string "SCRIPT Plane0"]:13: One of the function's argument type is not correct. (simSetShapeColor)
stack traceback:
[C]: in function 'simSetShapeColor'
[string "SCRIPT Plane0"]:13: in main chunk

I know that UnpackedString is a 'table floatingNumber' and simSetShapeColor need as a input argument simFloat* rgbData.
Maybe I have to convert UnpackedString in a right input value for simSetShapeColor.
Any suggestion?

Many thanks

coppelia
Site Admin
Posts: 7396
Joined: 14 Dec 2012, 00:25

Re: Error Using simSetShapeColor

Post by coppelia » 19 Oct 2017, 14:39

The function call looks fine. Make sure that handlePlane is a valid object handle, and that UnpackedString is really a table that contains 3 numbers.

Cheers

DavideIng
Posts: 39
Joined: 21 Sep 2017, 17:27

Re: Error Using simSetShapeColor

Post by DavideIng » 19 Oct 2017, 15:21

I checked but doesn't works again.
Vrep Plane1 (primitive shape) Non-Threaded Child Script:

Code: Select all

if(sim_call_type==sim_childscriptcall_initialization) then
simExtRemoteApiStart(20001)
Plane1Handle = simGetObjectHandle('Plane1')
r,initColor=simGetShapeColor(Plane1Handle,nil,0)
SentString = simPackFloatTable(initColor)

end

if (sim_call_type==sim_childscriptcall_actuation) then
GotString = simGetStringSignal('ChangeColor')
UnpackedString = simUnpackFloatTable(GotString)
--simAddStatusbarMessage('word')
simSetShapeColor(Plane1Handle,nil,0,UnpackedString)
 
end

if (sim_call_type==sim_childscriptcall_sensing) then
end

if (sim_call_type==sim_childscriptcall_cleanup) then
end
Any other suggestions?

Many thanks

coppelia
Site Admin
Posts: 7396
Joined: 14 Dec 2012, 00:25

Re: Error Using simSetShapeColor

Post by coppelia » 22 Oct 2017, 12:54

You need to tell us what exactly is not working. If a function fails, make sure to print out the arguments to verify those are exactly what you expect them to be. If they are not, then the error happened further up in the program.

Cheers

Post Reply