Constructing a Virtual Robot Three.js/WebGL

This post is about constructing a virtual robot WebGL experiment, using Threejs.org/examples as a starting point. The ultimate goal is to have a training robot similar to the ones used in automotive manufacturing. Note that, in this article I am trying out a bibliographical style where in post references are marked with a bracketed number, e.g. [1]; and the source is listed after a separator at the end of the post.

Given References:

  1. https://threejs.org/examples/#webgl_loader_collada_kinematics
  2. https://github.com/rdiankov/collada_robots
  3. http://openrave.org/docs/latest_stable/robots_overview/

The github project listed above had been cloned into:

/home/sparkone/projects/robotics/collada_robots

The collada_robots project cloned from github is a folder full of .zae files. (A .ZAE file is a Compressed COLLADA Digital Asset Exchange file [1]). Well it needs to be uncompressed using zip, after renaming .zae to .zip; placed in their own directory to avoid overwriting manifest.xml. This has been accomplished and now each uncompressed .dae file exists in its own folder.

Well then, what is COLLADA? COLLADA is an XML-based schema that enables you to transfer data among 3D digital content creation tools, such as SketchUp, Maya, 3ds Max, and Rhino [2].

Thus the project contains robot models only. Fortunately, we have an example related to this from the old WebGL book worked from on the old site.

The old project website book link is down, but the URL is: http://vorticieflux6626.ihostfull.com/oreilly/oreilly.php.

Went ahead and cloned all of https://github.com/mrdoob/three.js.git into:

/home/sparkone/projects/robotics/three.js

This includes the documents and examples, the particular one of interest is webgl_loader_collada_kinematics.

So the example needs to be isolated and analyzed, then ported onto hostgator’s server and linked.

Meanwhile, the openrave project seems promising for one of the ultimate goals of this particular project. To that end the following link is noted:

https://www.osrobotics.org/osr/installation/motion_planning.html

Apparently the software is intended to be installed on Ubuntu, however; it may be possible to install it on Arch Linux.

Using dpkg for this is a BadIdea™. The only sensible solution is to write a PKGBUILD (if one doesn’t already exist in the AUR) which extracts the contents of the deb and repackages them correctly for Arch.

– HalosGhostJan 15, 2015 at 13:51” – [3]. How are .deb packages compressed differently than they way they are in PKGBUILD?

  1. https://bbs.archlinux.org/viewtopic.php?id=244018.
  2. https://cubethethird.wordpress.com/2017/08/12/installing-debianubuntu-packages-on-arch-linux/

In order to rotate an arbitrary object using a 3d rotation matrix and vectors, the following post suggests that the object be translated to the origin, rotated then translated back.

https://math.stackexchange.com/questions/2093314/rotation-matrix-of-rotation-around-a-point-other-than-the-origin

“Your first formula is correct. Remember, the point to which this is applied appears on the RIGHT:

T(x,y)∗R∗T(−x,−y)(P)

So to evaluate the expression above, we first translate P by (−x,−y), then rotate the result, then translate back. Let’s see what happens when P is the point (x,y,1). That amounts to evaluating the following product:

f((x,y))=<mtable><mtr><mtd>1</mtd><mtd>0</mtd><mtd>0</mtd></mtr<><mtr>010</mtr><mtr>xy1</mtr></mtable>⎥⎡⎣⎢cos(θ)sin(θ)0−sin(θ)cos(θ)0001⎤⎦⎥⎡⎣⎢100010−x−y1⎤⎦⎥⎡⎣⎢xy1⎤⎦⎥=⎡⎣⎢100010xy1⎤⎦⎥⎡⎣⎢cos(θ)sin(θ)0−sin(θ)cos(θ)0001⎤⎦⎥⎡⎣⎢001⎤⎦⎥=⎡⎣⎢100010xy1⎤⎦⎥⎡⎣⎢001⎤⎦⎥=⎡⎣⎢xy1⎤⎦

as expected: the point (x,y) remains fixed by this composite transformation.” [4]


References:

  1. https://file.org/extension/zae
  2. http://help.sketchup.com/en/sketchup/importing-and-exporting-collada-files#:~:text=COLLADA%20is%20an%20XML%2Dbased,export%20COLLADA%20files%20pretty%20easily.
  3. https://unix.stackexchange.com/questions/179235/installing-ubuntu-debian-packages-on-arch
  4. https://math.stackexchange.com/questions/2093314/rotation-matrix-of-rotation-around-a-point-other-than-the-origin?newreg=50be929e5a6c4e9598467c545690fea5

“Thank you, this answer made it simple for me to create a Transformer class in javascript with chainable methods .set().translate().rotate() and .get(), allowing me to write un-nested expressions such as transformer.set(coords).translate([-4,4]).rotate(Math.PI/2).translate(4,-4).get();. Yay! 

– Roamer-1888Nov 15, 2021 at 18:18

Leave a Reply

Your email address will not be published. Required fields are marked *