question

Youichi I avatar image
1 Like"
Youichi I asked Youichi I commented

How to use initkinematics in the robot joint control?

I wrote the following code, but it is not reflected in Current position. How should I program it?

treenode trb;

Object orb = model().find("Robot8");

initkinematics(trb, orb, KINEMATIC_MANAGE_ROTATIONS);

initkinematics(trb, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, KINEMATIC_MANAGE_ROTATIONS);

addkinematic(trb, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 1,1,time(),KINEMATIC_TRAVEL);

updatekinematics(trb, orb); deactivatekinematics(trb);

FlexSim 18.1.2
robot arm
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Joerg Vogel avatar image
2 Likes"
Joerg Vogel answered Youichi I commented

The node reference trb must be a real node in the tree. Typically you use a label at the robot for this task.

treenode robot = Model.find(“your own robot”);
robot.labels.assert(“yourKinematicNode”);
treenode trb = robot.labels[“yourKinematicNode”];
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image Mischa Spelt commented ·

Jörg, it may be worth adding that the last line is only used later in the code, when you need to access the label and already know it exists.

When creating it, I would grab the result from the assert:

treenode trb = robot.labels.assert(“yourKinematicNode”);
1 Like 1 ·
Youichi I avatar image Youichi I commented ·

Jörg and Mischa,

Thank you for reply.

I modifed my script. But, I didn't set 10.0 to joint1.

Could you help me.

treenode robot = model().find("Robot8");

treenode trb = robot.labels.assert("variables/robotkinematics");

Object orb = model().find("Robot8");


initkinematics(trb, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, KINEMATIC_MANAGE_ROTATIONS);
updatekinematics(trb, orb);
deactivatekinematics(trb);

0 Likes 0 ·
Brandon Peterson avatar image Brandon Peterson ♦ Youichi I commented ·

The kinematic functions define the movement for a single object. Your code is defining the movement of the robot (the base) and not for the robot's joints. The reason that joint1 was not set to 10 is because the definition of the initkinematics() function says that you set the Robot's x location to 10 (y=20,z=30,xr=40,etc.). If you want to create kinematics for different parts of the robot then you will need to create a separate kinematic label for each part of the robot that you want to move.

I have included some highlights from the code on the robot that moves the arm that should help you out (I made some modifications to make it work in Flexscript):

Object robot = Model.find("Robot1");
treenode base = first(robot.find(">visual/drawsurrogate"));
treenode joint1 = first(base);
treenode joint2 = first(joint1);
treenode joint3 = first(joint2);
treenode joint4 = first(joint3);
treenode joint5 = first(joint4);
treenode joint6 = first(joint5);
treenode kinvariable = getvarnode(robot, "robotkinematics");
treenode joint1kin = rank(kinvariable, 1);
treenode joint2kin = rank(kinvariable, 2);
treenode joint3kin = rank(kinvariable, 3);
treenode joint4kin = rank(kinvariable, 4);
treenode joint5kin = rank(kinvariable, 5);
treenode joint6kin = rank(kinvariable, 6);
initkinematics(joint1kin, joint1, 0,0);
initkinematics(joint2kin, joint2, 0,0);
initkinematics(joint3kin, joint3, 0,0);
initkinematics(joint4kin, joint4, 0,0);
initkinematics(joint5kin, joint5, 0,0);
initkinematics(joint6kin, joint6, 0,0);

After the above code that initializes the kinematics for each joint the code goes on to add kinematics for the movement of each joint.

I hope this helps get you on track, Brandon

1 Like 1 ·
Youichi I avatar image Youichi I Brandon Peterson ♦ commented ·

Brandon-san,

Thank you so much !

I can now control the flexsim robot in FlexScript.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.