Position and Orientation control with one command

Typically: "How do I... ", "How can I... " questions
muhammad.khan
Posts: 5
Joined: 13 Apr 2021, 12:10

Position and Orientation control with one command

Post by muhammad.khan »

Hi, can we use one single command to control the robot end effector position and orientation together, instead of separately. This apparently causes problems in inv kinematics.

Any suggestions would be appreciated.

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

Re: Position and Orientation control with one command

Post by coppelia »

Hello,

yes, you can do this with sim.setObjectMatrix or sim.setObjectPose.
However, using two separate API functions (e.g. sim.setObjectPosition and sim.setObjectOrientation or sim.setObjectQuaternion) should not cause any problems, even with threaded script, if done correctly:

Code: Select all

function coroutineMain()

    ...
    
    local forbidLevel=sim.setThreadAutomaticSwitch(false)
    -- Following 3 API commands are not executed without interruption:
    sim.setObjectPosition(handle,-1,position)
    sim.setObjectOrientation(handle,-1,euler)
    sim.setThreadAutomaticSwitch(forbidLevel)

    ...

end
Cheers

muhammad.khan
Posts: 5
Joined: 13 Apr 2021, 12:10

Re: Position and Orientation control with one command

Post by muhammad.khan »

Thank you, I use matlab API to do this. there is mostly a misalignment of tip and target frames. Is there some tolerance factor that i should expect. or it must be 100% accurate if everything is setup correctly even when i use setposition and setorientation separately.

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

Re: Position and Orientation control with one command

Post by coppelia »

you are talking about several things here. You first need to rule out several things, e.g. such as:
  • you have some communication delay between CoppeliaSim and the client application. Moreover, if you do not run in synchronous mode and/or in real-time mode, you will see differences
  • you are talking about tip and target frames. Does that mean you run some inverse kinematics? If yes, then the IK itself will need 1-n simulation passes to bring the tip closer to the target, depending on the resolution method and other IK settings. Moreover, if your robot is dynamically enabled, then the tip-target overlap quality will also depend on the various joint controllers and physical properties of the joint and links.
So best is to first test these things by trying to have the legacy remote API client follow some simple moving object that is not linked to IK or a robot.

Cheers

Marcelbgit
Posts: 10
Joined: 01 Dec 2021, 12:27

Re: Position and Orientation control with one command

Post by Marcelbgit »

Dear Coppelia team,

I also tried to set the position and orientation directly with your recommended commands. But the problem is, that the dummy Panda_tip moves upwards but not the rest of the robot (joints)arrange/follow. I also tried it with the Panda robot endeffector but without any success. Can you help me out, how to set or arrange the whole robot with the setObjectPosition/Orientation command?

Code: Select all

function sysCall_init()
	tipHandles=sim.getObjectHandle(Panda_tip)
	pos={0.2900,-0.0100, 1.8720}
	eul={180.00, 013.89, -180.00}
	local forbidLevel=sim.setThreadAutomaticSwitch(false)
	sim.setObjectPosition(tipHandles, -1, pos)
	sim.setObjectPosition(tipHandles, -1, eul)
	sim.setThreadAutomaticSwitch(forbidLevel)
unfortunately I don't get how to add the image here
Image
cheers,
Marcel

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

Re: Position and Orientation control with one command

Post by coppelia »

Hello Marcel,

you have several problems in your script:
  • you are using sim.setObjectPosition instead of sim.setObjectOrientation for the Euler angles
  • your Euler angles should be expressed in rad, not degrees
  • since you are in a non-threaded section, you do not have to use sim.setThreadAutomaticSwitch
Once fixed, your object should move into the desired position and orientation. If there is some IK linked to that object, then this is another problem and you will have to look into why your IK is not working.

Cheers

Marcelbgit
Posts: 10
Joined: 01 Dec 2021, 12:27

Re: Position and Orientation control with one command

Post by Marcelbgit »

Hello,

thanks for your help and your reply.
My object is moving to the proper position and orientation. But the rest of the robot still doesn't follow. I will send you the image via wetransfer. My aim is to subscribe the endeffector pose of my robot via ROS and change the endeffector pose plus the rest to the subscribed pose at the beginning once. To make it more feasible I have used the Panda_gripper instead of the Panda_tip (what describes the TCP/endeffector frame here)

https://we.tl/t-upueg7daQC

Cheers,
Marcel

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

Re: Position and Orientation control with one command

Post by coppelia »

You are still using an old version of CoppeliaSim. Please use CoppeliaSim V4.3 or later. The scene or the robot model is also still using the old IK functionality (the one that had to be set-up via GUI). Since CoppeliaSim V4.2 or later, IK tasks are set-up entirely via code, which makes everything much more scalable and easy to use.

Please post the scene, a screenshot is not really useful.

Cheers

Marcelbgit
Posts: 10
Joined: 01 Dec 2021, 12:27

Re: Position and Orientation control with one command

Post by Marcelbgit »

Thanks for your help and reply! I know but for the work I am doing only CoppeliaSim V4.1 is supported. To clarify, in the old version there is no automated way to set the endeffector frame (and the associated links) to a certain position, right? So the joints need to set manually to the desired position. My goal is to open the scene and the robot already fits to the desired endeffector position (the positions of joints are negligible).

Cheers,
Marcel

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

Re: Position and Orientation control with one command

Post by coppelia »

if you are able to move the target object into the correct position and orientation, but the robot does not follow, then you have a problem with IK.
Either IK is not properly defined, or your IK is not able to properly execute. Keep in mind that you can't make bit jumps with IK, you will have to move gradually, step-by-step until you reach the target position/orientation. You can of course also directly compute the joint configuration that corresponds to a given end-effector pose with simIK.findConfig. That API command is not yet available in CoppeliaSim V4.1, and in that case you should use sim.getConfigForTipPose.

Cheers

Post Reply