question

立洲 avatar image
0 Likes"
立洲 asked Jason Lightfoot edited

How to collect the current position of the robot arm X, Y, Z axis

我收集機械臂每次改變運動的XYZ軸坐標並需要寫入表格(位置表)

我應該如何獲得這些信息,希望你能幫我修改這個模型並得到一個可以解決問題的答案,謝謝。

Collect robot arm axis coordinates.fsm

Translation: "I collect the XYZ axis coordinates of each movement of the robotic arm and need to write to a table (position table) How should I get this information, I hope you can help me modify this model and get an answer that can solve the problem, thanks."

FlexSim 20.0.10
globaltablerobot armaxis
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered 立洲 commented

It sounds like you want to use getLocation, rotation and project which will allow you to easily find all required x,y,z relative to your desired coordinate space. Assign them to a Vec3, say, armLoc1, and then access them using armLoc1.x, armLoc1.y, armLoc1.z.

You may need to run updatelocations on the objects before you access them.

· 7
5 |100000

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

立洲 avatar image 立洲 commented ·

是的,這就是我想做的

有沒有可以給我參考的例子?


Translation: "Yes, that's what I want to do. Is there an example that I can refer to?"

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ 立洲 commented ·

There's not that much to it. Let's say you want to find the coordinate of the centre of joint6 in model space (the root of the model tree).


Object joint6=Model.find("Basic /Joint 1/Joint 2/Joint 3/Joint 4/Joint 5/Joint 6");
Vec3 j6loc=joint6.getLocation(0.5,0.5,0.5);   //  The location of joint6 in it's container's space.  Use 0.5 for x,y and z meaning he center of the bounding box
Vec3 j6modelCoords=j6loc.project(joint6.up, model());  // translates the joint5 coordinates to model coordinates.
applicationcommand("outputconsole");
print("X:",j6modelCoords.x,"Y:",j6modelCoords.y,"Z:",j6modelCoords.z);

I see in your model that you've not put the joints in the correct locations. If you want to try that, use the centroid attribute in the tree (">spatials/centroid"). Set its value to 2 and then add 3 nodes for the coordinates of the joint relative to the objects own coordinate space.

1651493694225.png


0 Likes 0 ·
1651493694225.png (2.7 KiB)
立洲 avatar image 立洲 Jason Lightfoot ♦♦ commented ·

Thank you, this answer helped me a lot

I also want to know, how to replace outputconsole with Global Table

I need to use Global Table to collect this relevant information

0 Likes 0 ·
Show more comments