Robot Position

Typically: "How do I... ", "How can I... " questions
Post Reply
Pikapi
Posts: 14
Joined: 31 Jul 2013, 09:26

Robot Position

Post by Pikapi » 13 Aug 2013, 15:04

Hi, i would like to ask may i know how to set the condition for the robot when it reach the position?

Code: Select all

if(sensorResult==1)then
			if(currentConf[1]>0.1)then
				currentConf={currentConf[1]-0.001,currentConf[2],currentConf[3]}
			end
			if(currentConf[1]<0.1)then
				currentConf={currentConf[1]+0.001,currentConf[2],currentConf[3]}
			end
                        if(currentConf[1]==0.1)
                                activateSuctionPad(false)
                        end
end
the above is my code for a robotic arm to go to direction X, when it reach point 0,1, the suction pad will be deactivated. However, it doesn't run the code "if(currentConf[1]==0.1)". Thanks.

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

Re: Robot Position

Post by coppelia » 13 Aug 2013, 15:07

Make sure not to forget the then in the if-then-end construct! (the last if-then-end)

Cheers

Pikapi
Posts: 14
Joined: 31 Jul 2013, 09:26

Re: Robot Position

Post by Pikapi » 13 Aug 2013, 15:35

sorry about that, I had put in "then". But it still doesn't work.

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

Re: Robot Position

Post by coppelia » 13 Aug 2013, 17:09

Not sure what your code is doing exactly, but try to avoid conditions that involve equalities such as:

Code: Select all

if (positionX==0.2) then
    -- do something
end
Because they might never be executed due to floating-point or algorithm precision.

Cheers

Pikapi
Posts: 14
Joined: 31 Jul 2013, 09:26

Re: Robot Position

Post by Pikapi » 13 Aug 2013, 19:22

Hi, okay Thanks. I have another question. How i can move the position of the robotic arm irb140 in non-threaded child script? As I know simMoveToPosition can only be used in threaded child script. Thanks.

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

Re: Robot Position

Post by coppelia » 13 Aug 2013, 20:44

Please post a new topic next time, if the question is not related to the initial topic.

From a non-threaded child script you can set the target position of the robot tip (since the IRB140 model you are talking about is controlled in IK) by setting a new position instantaneously for the target dummy object (IRB140_target). Use the api functions simSetObjectPosition and simSetObjectOrientation for that.

Cheers

Post Reply