Automated Parking Garage

Typically: "How do I... ", "How can I... " questions
rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Automated Parking Garage

Post by rjhkm » 19 Nov 2014, 08:00

I am trying to create a rotary automated parking system as in the image below:

Image

The difference between the model in the image above with mine is that the one from the image has 8 platforms, while mine only has 6.

I have created the complete mechanical drawing, and transferred it into V-REP. You can see my progress by downloading the .ttt file from the link below.:

http://www.filedropper.com/automatedparkinggarage

What I would like to know is how to be able to create a custom user interface with 6 buttons, labeled 1 - 6, each to call different platforms to ground level. I almost completely have no idea about programming and so I want to know which syntax, for example, I need to use and other information needed to simulate the system in such a way.

Thanks for your help in advance.

Regards

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

Re: Automated Parking Garage

Post by coppelia » 19 Nov 2014, 17:33

Hello,

a little tip for your scene: make a model for one of the 6 platforms, and mark it as Object/model can transfer or accept DNA. This way, if at a later point you need to modify all 6 platforms, then you could simply modify one of them, and transfer the DNA to the other platforms (i.e. effectively making them identical) with a simply click of a toolbar button.

For the custom user interface you need, simply enter the custom user interface edit mode, then click Add new user interface. For Client y-size, enter 13, then click OK. Rename your user interface to something useful, e.g. platformCmd. You can do this with a double-click onto the appropriate UI in the list on the left hand side.

Then select the two first empty cell rows (using the shift-key) and click Insert merged button. Write down the Button handle number. Repeat this step for the other buttons.

Then leave the custom user interface edit mode and inside of a child script, use something like (in case of a non-threaded child script):

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
	uiHandle=simGetUIHandle('platformCmd')
end

if (sim_call_type==sim_childscriptcall_actuation) then
	local eventButton=simGetUIEventButton(uiHandle)
	if eventButton==buttonHandle1 then
		-- react to a click onto the first button
	end
	if eventButton==buttonHandle2 then
		-- react to a click onto the second button
	end
	-- etc.
	
end
Cheers

rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Re: Automated Parking Garage

Post by rjhkm » 21 Nov 2014, 03:33

Thank you very much for your help it's gotten me further into the simulation.

There are a few more things I need to know. Firstly, I would like to know how can I order a path to move in a certain direction for 1/6 of it? Is it possible to move a dummy in counter- and clockwise directions along a path? The question comes to mind since there is a "Target Nominal Velocity" value for the path and positive and negative values represent different directions of the movement.

Secondly, I would like to know how can the system be informed which platform lies in which position? I need this to be able to call a specific platform to the gate position. For example, platform 1 lies at position 3 as illustrated in the image below.

Image

The numbers inside the boxes denote the platform numbers, while those just outside them are the position names. If a number 1 is pressed on the UI, that means said platform is required to go to the gate position. Therefore, the system needs to know how many positions does the platform need to be shifted by. For example, using the same instance of the system, number 5 is pressed on the UI. Instead of shifting the platform clockwise by 5 positions, it can simply shift it by 1 position counter-clockwise. And more importantly, to be able to perform these actions, the system needs to, firstly, be able to tell which positions each platforms lie in.

Again, I thank you in advance and any kind of help would be much appreciated.

Regards

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

Re: Automated Parking Garage

Post by coppelia » 21 Nov 2014, 12:03

You can directly control the movement with simSetPathTargetNominalVelocity.

In order to have full controll of an object along the path, you could also use following API functions:
As for knowing the position of the individual platforms, there are several ways:
  • read out the position (with simGetObjectPosition) of a dummy object on each platform. Depending on the 3D coordinate of those dummies, you can figure out the state of the platforms.
  • use a proximity sensor to detect a specific dummy object on each platform.
Cheers

rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Re: Automated Parking Garage

Post by rjhkm » 24 Nov 2014, 08:56

Thank you for your reply.

On your recommendation, which function should I use if if upon pressing any of the buttons, I need to move everything that lies on the path? But, as I have mentioned earlier, a specific button corresponds to a specific platform, and to place said platform on the gate position, the button which it corresponds to needs to be pressed.

I also would like to know, which object should I associate the script with?

Thank you for your help,
Regards

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

Re: Automated Parking Garage

Post by coppelia » 24 Nov 2014, 11:08

Best would be to have the base object of your whole mechanism associated with a child script. Have also the custom user interface attached to that base object.

The rest is just a matter of programming: you will have to identify which button you pressed, and in what positions your platforms are. Then you can move all platforms forward or backwards.

Cheers

rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Re: Automated Parking Garage

Post by rjhkm » 29 Nov 2014, 05:29

Could you please tell me what I did wrong in this segment?

Code: Select all

	if (btID==3) then
	finalPos=simGetObjectPosition(dummy0,-1)
      while dumPos~=finalPos do
		simSetPathTargetNominalVelocity(path,0.05)
		dumPos=simGetObjectPosition(dummy,-1)
	  end
	end
where:
- btID is the button handle;
- dumPos is the position of the object declared as 'dummy' ; and
- finalPos is the position of the object declared as 'dummy0'.



In this segment, what I am trying to achieve is for the circular path to rotate until the position of 'dummy' is the same as the position of 'dummy0'. I have set the property of 'dummy' to be "Fixed on Path", while 'dummy0' is set to "Free on Path".

Everything goes as expected up to the point where the path should stop rotating; the path does not rotate until the button is pressed. But as 'dummy' reaches 'dummy0', the path continues to rotate and does not stop.

Thank you again in advance.
Regards

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: Automated Parking Garage

Post by Eric » 29 Nov 2014, 07:46

hi...

Not sure but, you don t seem to be stopping the the motion.... Also, if you are using a non threaded script, having a blocking while loop is not a good idea... it will block the simulation. Last thing... the positions will never be exactly the same so u d never stop as the condition dumPos~=finalPos will always be true. So you have to check that the Euclidean distance between the two dummies is less than a small distance.

So maybe something like that:

Code: Select all

   --defining target based on pressed button
   if (btID==3) then
       finalPos=simGetObjectPosition(dummy0,-1)      
       simSetPathTargetNominalVelocity(path,0.05)
   end

   dumPos=simGetObjectPosition(dummy,-1)
   if math.sqrt((dumPos[1]-finalPos[1])^2+(dumPos[2]-finalPos[2])^2+(dumPos[3]-finalPos[3])^2)< 0.0001 do --stop the motion
      simSetPathTargetNominalVelocity(path,0.)
   end
cheers

Eric

PS: finalPos needs to be initialized once ( and only once) at the beginning of the script (in the sim_childscriptcall_initialization phase), by something unreachable like finalPos={9999999,999999,999999}

rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Re: Automated Parking Garage

Post by rjhkm » 30 Nov 2014, 17:37

Thank you Eric for you help. I've gotten into more trouble here with this code:

Code: Select all

if (sim_call_type==sim_childscriptcall_actuation) then
	dumPos=simGetObjectPosition(dummy,-1)
	finPos=simGetObjectPosition(dummy0,-1)
	posX=dumPos[1]-finPos[1]
	posY=dumPos[2]-finPos[2]
	abDis=math.sqrt(((posX)^2)+((posY)^2))
	ab=abDis*4000
	disR=math.floor(ab)
		if (btID==3 and disR~=0) then
			simSetPathTargetNominalVelocity(pathHandle,0.01)
		elseif (disR1==0) then
			simSetPathTargetNominalVelocity(pathHandle,0)
		end

	dumPos1=simGetObjectPosition(dummy1,-1)
	finPos=simGetObjectPosition(dummy0,-1)
	posX1=dumPos1[1]-finPos[1]
	posY1=dumPos1[2]-finPos[2]
	abDis1=math.sqrt(((posX1)^2)+((posY1)^2))
	ab1=abDis1*4000
	disR1=math.floor(ab1)
		if (btID==6) then
			simSetPathTargetNominalVelocity(pathHandle,0.01)
		elseif (disR1==0) then
			simSetPathTargetNominalVelocity(pathHandle,0)
		end
end
The problem with this code is that upon pressing button 6, the path stops moving when 'dummy' reaches 'dummy0' when it should stop when 'dummy1' reaches 'dummy0' instead.

How do I press button 3 and get 'dummy' to go to the position of 'dummy0', and press button 6 and get 'dummy1' to the position of 'dummy0'?

Thank you in advance
Regards

rjhkm
Posts: 6
Joined: 11 Nov 2014, 16:56

Re: Automated Parking Garage

Post by rjhkm » 02 Dec 2014, 11:50

I am now trying to create a number panel. I am still trying to figure out the user interface through experimentation and I think I'm at lost with this code:

Code: Select all

rlg=simGetUIHandle("UI")
rID=simGetUIEventButton(rlg)

code1=0
code2=0

simSetUIButtonLabel(rlg,3,code1..code1)

if (rID==1) then
        code1=1
        simSetUIButtonLabel(rlg,3,code1..code2)
elseif (rID==5) then
	simSetUIButtonLabel(rlg,3," ")
end
What I am trying to achieve through the above code is for button 3 to display "10" when I press button 1, and clear (displaying <space> as) the label of button 3 upon pressing button 5. I have set button 3 to "Label".

Could anyone please tell me what I did wrong or didn't do?

Thank you in advance for your help.
Regards

Post Reply