Problems with resetting robot back to initial position

Typically: "How do I... ", "How can I... " questions
Post Reply
mthor13
Posts: 9
Joined: 03 Jul 2017, 08:32

Problems with resetting robot back to initial position

Post by mthor13 » 14 Feb 2018, 15:59

Hi CoppeliaRobotics,

I'm currently working on a project where I to repeat an experiment multiple times.
I'm controlling my simulated robot through ROS, so I thought that the smartest thing would be to just reset to robot back to its initial position and orientation (that way I do not have to stop and start the simulation - and reconnect the ROS nodes).

However, after a few reset's some parts tend to "float"/move away from their desired attachment points (see picture).

How it should be:
Image

How it is after few resets (in this case the force-sensor and angle joint moves out of place):
Image

My resetting code is as follows and is placed in the actuator section of the child script:

Code: Select all

    if(testParameters[2] > 45) then
        --moving the dynamic object
        t={robotHandle}
        while (#t~=0) do
            h=t[1]
            simResetDynamicObject(h)
            table.remove(t,1)
            ind=0
            child=simGetObjectChild(h,ind)
            while (child~=-1) do
                table.insert(t,child)
                ind=ind+1
                child=simGetObjectChild(h,ind)
            end
        end
        --moving the robot to the initial position  and orientation (i.e. where the simulation started)
        sim.setObjectPosition(robotHandle,-1,initialPosition)
        sim.setObjectOrientation(robotHandle,-1,initialOrientation)
        sim.resetDynamicObject(robotHandle)
    end
I am also open to other ways of resetting the robot as I plan to do evolutionary programming in the future.

Best Regards & Thanks in advance,
Mathias Thor

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

Re: Problems with resetting robot back to initial position

Post by fferri » 14 Feb 2018, 23:15

Sorry, I don't have a solution to your robot model issue.

But another thing you can try is to use a customization script to create a ROS node. That would persist across multiple simulation sessions, i.e. the ROS node would remain active after you stop the simulation.

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

Re: Problems with resetting robot back to initial position

Post by coppelia » 15 Feb 2018, 09:26

Hello,

have also a look at this topic.

Cheers

mthor13
Posts: 9
Joined: 03 Jul 2017, 08:32

Re: Problems with resetting robot back to initial position

Post by mthor13 » 15 Feb 2018, 11:03

Thanks Fferri and Coppella!

Post Reply