Tutorial PracticalPathPlanning.ttt

Typically: "How do I... ", "How can I... " questions
Post Reply
adityaraj52
Posts: 11
Joined: 19 Jun 2013, 14:29

Tutorial PracticalPathPlanning.ttt

Post by adityaraj52 » 06 Jul 2013, 12:21

In the child script of dr_12 robot, I can't get how a force sensor can avoid obstacles and that too using force sensors.

Code: Select all

targetP=simGetObjectPosition(targetHandle,-1)
vv={targetP[1]-desiredTargetPos[1],targetP[2]-desiredTargetPos[2]}
if (math.sqrt(vv[1]*vv[1]+vv[2]*vv[2])>0.01) then
	pathCalculated=0 -- We have to recompute the path since the target position has moved
	desiredTargetPos[1]=targetP[1]
	desiredTargetPos[2]=targetP[2]
end


currentTime=simGetSimulationTime()
result,f,t=simReadForceSensor(bumperSensorHandle)
if (result>0) then
	if (math.abs(f[2])>1) or (math.abs(f[3])>1) then
		backwardModeUntilTime=currentTime+3 -- 3 seconds backwards
	end
end
1) I am unable understand this part of the code. You have stored the the force vector in an array f and result also stores the reading of the force sensor. But how readings of a force sensor going to avoid obstacles?

2)Can we replace force sensors by VisionSensors?

3)Also you have initialised desiredTargetPosition ={-99,99}. How is this helping us in the calculation of the movement of the target position?

4)Also how (math.sqrt(vv[1]*vv[1]+vv[2]*vv[2])>0.01) is telling us the target has moved?

5)I also tried the automatic path planning functionality of your demo 3DoFHolonomicPathPlanning.ttt. But as soon as I increase the distance it doesn't work. It only works for smaller distance say 2m. If the distance between the dummy objects is more than 2m we can't search the path.

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

Re: Tutorial PracticalPathPlanning.ttt

Post by coppelia » 08 Jul 2013, 13:24

Hello,

The code you mention is located in the child script attached to the robot model dr12_robot_, in the demo scene practicalPathPlanningDemo.ttt.

About your questions:
  • The reading of the force sensor is not going to avoid obstacles. But since obstacles can be dynamically moved around, it can happen that the robot collides with an obstacle. And when that happens, a new collision-free path will be calculated.
  • Yes, you can replace the force sensor with a vision sensor. You will however have to evaluate the vision sensor and generate collision signals.
  • Initializing desiredTargetPosition to a large value has the effect that a new path calculation will be triggered. Same as if you manually move the target position around.
  • Everytime you move the target position, previous target position is stored. Then, only if the difference with previous position is large enough will a new path be calculated
  • Have a close look at the 3DofHolonomicPathPlanning.ttt demo scene: in the path planning dialog, select the task pathPlanningTask and then click Adjust search parameters: there you can adjust the parameters and for instance increase the search area. But remember that a larger search area will also take more calculation time.
Finally, the demo scenes are just examples: there are many many different ways of solving problems, and the featured algorithms are not always the most efficient or the most elegant ;)

Cheers

Post Reply