Hello,everyone
I want a infinite floor,and when model is moving,object's position is also changing .But when i choose a infiniterFloor.ttm scence, the model's position is not changing ,but i need the position message . I do not know what should i do so that i can get a infinite floor ,and position message change with moving.
Look forward to your replay!
a moving object's position is not changing in infinitefloor
Re: a moving object's position is not changing in infinitefloor
Hello,
the infinite floor is designed to keep the robot (or scene content) near the origin. In order to get an idea of travelled distances, you'll have to extract the x/y distance that the floor corrected. For that, open the child script attached to the infinite floor, and add:
at the end of the initialization function. Then add:
at the end of the actuation function. That will print the total shift the floor did. So you'll simply have to add that shift to the position of your robot, to get the real travelled distance.
Simplest is to put that shift in a string signal (also at the end of the actuation function):
and in your robot's script, you can do:
Cheers
the infinite floor is designed to keep the robot (or scene content) near the origin. In order to get an idea of travelled distances, you'll have to extract the x/y distance that the floor corrected. For that, open the child script attached to the infinite floor, and add:
Code: Select all
totalShift={0,0}
Code: Select all
totalShift[1]=totalShift[1]+dx
totalShift[2]=totalShift[2]+dy
print(totalShift)
Simplest is to put that shift in a string signal (also at the end of the actuation function):
Code: Select all
sim.setStringSignal('floorShift',sim.packTable(totalShift))
Code: Select all
local robotPosition=sim.getObjectPosition(robotHandle,-1)
local data=sim.getStringSignal('floorShift')
if data then
data=sim.unpackTable(data)
robotPosition[1]=robotPosition[1]+data[1]
robotPosition[2]=robotPosition[2]+data[2]
end