Hi!
I recently started using Coppeliasim for my final year project, I am new with it.
I need help regarding making the dummy follow a specific path using x y coordinates. I know about a method to import the coordinates from a csv file, and it worked, but I need help in generating a path using the data from that csv file. I used some of the codes I found on the forums here and there, but I keep getting the error: "createpath: argument 1 must be a table of elements of type float".
Can someone please help me with this issue?
Thanks in advance!
Inserting a path using x y coordinates
Re: Inserting a path using x y coordinates
Hello,
here a simple example, creating a path with 4 control points located at (0,0,0),(1,0,0),(1,1,0),(0,1,0):
Cheers
here a simple example, creating a path with 4 control points located at (0,0,0),(1,0,0),(1,1,0),(0,1,0):
Code: Select all
local ctrlPts={0,0,0,0,0,0,1,
1,0,0,0,0,0,1,
1,1,0,0,0,0,1,
0,1,0,0,0,0,1}
sim.createPath(ctrlPts,0,100,0)
-
- Posts: 16
- Joined: 27 Nov 2021, 19:41
Re: Inserting a path using x y coordinates
Thanks a lot for your reply!
From what I understand, the first 6 elements of the coordinates are for the 6 direction movement. But I'm not too sure about the last ones.
Can you please elaborate the syntax about the 28 elements in the code?
Thanks!
From what I understand, the first 6 elements of the coordinates are for the 6 direction movement. But I'm not too sure about the last ones.
Can you please elaborate the syntax about the 28 elements in the code?
Thanks!
Re: Inserting a path using x y coordinates
Each item is a pose (3 values for X/Y/Z position, 4 values for unit quaternion).
See for example sim.getObjectPose
See for example sim.getObjectPose
-
- Posts: 16
- Joined: 27 Nov 2021, 19:41
Re: Inserting a path using x y coordinates
Hi!
Thanks! Using this syntax, the path can be created now. But my original question, regarding how can I create a path using a csv file? I keep getting the error: "createpath: argument 1 must be a table of elements of type float", even though Coppelia reads the file and inputs it. How can this be solved to create the path now?
Thanks! Using this syntax, the path can be created now. But my original question, regarding how can I create a path using a csv file? I keep getting the error: "createpath: argument 1 must be a table of elements of type float", even though Coppelia reads the file and inputs it. How can this be solved to create the path now?
Re: Inserting a path using x y coordinates
Simply read the file line by line, split by comma, convert the values to numbers, and add those values to the path table.
E.g.:
E.g.:
Code: Select all
local path={}
for line in io.lines('path.csv') do
for x in string.gmatch(line,'([^,]+)') do
table.insert(path,tonumber(x))
end
if #path%7~=0 then error('incorrect number of columns in CSV') end
end