Domanda

To control a robotic arm, I have a controller with 6 dimensions (x, y, z position, and roll, pitch, yaw rotation). I am using a position (x, y, z) and quaternion (x, y, z, w) to represent the desired position and orientation of the robot's gripper.

I am using some libraries that people might not be familiar with (namely, geometry_msgs from ROS), so here is what I'm doing in pseudocode:

while(true):
  new_position = last_position + (joy.x, joy.y, joy.z)
  new_quaternion = last_quaternion * quaternionFromRPY(joy.roll, joy.pitch, joy.yaw)

  // (Compute inverse kinematics using position and orientation, then send to robot arm)

  last_position = new_position
  last_quaternion = new_quaternion

  delay(dt)

I am able to set the x, y, and z of the position part of the pose just fine. Technically, I am also able to set the quaternion just fine as well, but my problem is that controlling the quaternion is extremely non-intuitive, since rotation is not commutative. i.e., if I rotate 180 degrees about the x-axis, then the control of the rotation about the z-axis gets inverted.

Is there any way that I can control the rotation from a sort of "global reference frame," if that makes any sense? I would like it so that if I twist the joystick clockwise about z, the pose will rotate accordingly, instead of "sometimes rotating clockwise, sometimes rotating counterclockwise."

È stato utile?

Soluzione

Isn't this just as simple as exchanging the order of the factors in the quaternion product?

A unit quaternion q transforms a vector v in local coordinates to the rotated vector q*v*q' in global coordinates. A modified quaternion a*q*b (a, b also unit quaternions) transforms v as

a*(q*(b*v*b')*q')*a', 

where the b part can be interpreted as rotation in local coordinates and the a part as rotation in global coordinates.

So to apply a rotation in global coordinates only, set b=1, i.e., leave it out, and put the desired rotation in the a factor.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top