How can I input sequence of Pose into Coppelisasim just to display animation?

Typically: "How do I... ", "How can I... " questions
Post Reply
linzijie876
Posts: 8
Joined: 06 Apr 2023, 10:05

How can I input sequence of Pose into Coppelisasim just to display animation?

Post by linzijie876 »

I simulate a complex mathematical model in MATLAB to get a sequence of Pose(Frame Transformation Matrix) of a complex Robot.

In order to clearly display my results, I want to input this sequence of Transformation Matrix into Coppeliasim for animation.
So, the Robot can move in the coppeliasim.

Just for animation in Coppeliasim, Not for ODE simulation.

How can I easily solve this issue?

fferri
Posts: 1231
Joined: 09 Sep 2013, 19:28

Re: How can I input sequence of Pose into Coppelisasim just to display animation?

Post by fferri »

Make sure the object to animate is static, then apply the poses sequentially with sim.setObjectPose, e.g.:

Code: Select all

function sysCall_init()
    handle = sim.getObject '.'
    poses = { {0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 1}, ... }
end

function sysCall_actuation()
    index = (index or 0) + 1
    if index <= #poses then
        sim.setObjectPose(handle, poses[index])
    end
end

linzijie876
Posts: 8
Joined: 06 Apr 2023, 10:05

Re: How can I input sequence of Pose into Coppelisasim just to display animation?

Post by linzijie876 »

fferri wrote: 05 Apr 2024, 10:30 Make sure the object to animate is static, then apply the poses sequentially with sim.setObjectPose, e.g.:

Code: Select all

function sysCall_init()
    handle = sim.getObject '.'
    poses = { {0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 1}, ... }
end

function sysCall_actuation()
    index = (index or 0) + 1
    if index <= #poses then
        sim.setObjectPose(handle, poses[index])
    end
end

Can this script of codes be a input file?
e.g. A .txt file to record these codes?

fferri
Posts: 1231
Joined: 09 Sep 2013, 19:28

Re: How can I input sequence of Pose into Coppelisasim just to display animation?

Post by fferri »

Yes, you can use e.g. a text or csv file...

Code: Select all

poses = {}
for line in io.lines('poses.csv') do
    local pose = map(tonumber, string.split(line, ','))
    table.insert(poses, pose)
end

Post Reply