Tethering objects to the camera.

80 views
Skip to first unread message

Jason Lei

unread,
Jul 25, 2016, 9:53:55 AM7/25/16
to pi3d
Hi guys,

First time posting here. I would like to firstly introduce myself and what I'm working on before presenting my issue. My name is Jason, I am currently a university student at the University of Western Australia and am apart of a team of students developing a Solar Vehicle. One of the potential parts/accessories we are developing for this is a AR headset for HUD/Telemetry.

Now for the problem. We're currently running Pi3D on a Raspberry Pi and have interfaced an IMU. This is all working perfectly, we have the camera working etc. What isn't is getting an angle from the Camera to a Shape.

Essentially, we would like a floating GUI to follow (in an orbital fashion) the cameras Yaw rotation (Y-Axis Rotation) when the cameras view gets to the edge of the last GUI element (left or right side).

My question is, does Pi3D have any functions that will allow me to check the local angle between the camera and another shape?

Kind Regards,
Jason.

Paddy

unread,
Jul 25, 2016, 11:34:49 AM7/25/16
to pi3d
Hi, firstly, have you looked at or been in contact with a couple of other people doing vaguely related things Matt Coleman http://diydrones.com/profiles/blogs/raspihud-ground-based-hud-without-fpv and github/avishorp https://www.youtube.com/watch?v=sF4Ie8EQ8uY and @cowminer27 https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=153180&p=1013948

second, I've very recently added some functionality to the github/tipam/pi3d develop branch that allows the Camera to be rotated relative to its rotated position, very much as would happen with gyroscope inertial control. There are two additional functions in Camera now that can be used a) to get the Euler angles required to get to the current Camera rotation b) to get the rotational matrix required to move from one direction vector to another. Examples of how these could be used are here https://github.com/pi3d/pi3d_demos/blob/develop/ForestStereo.py#L156

but you can get the vector as a numpy array from the Camera to a Shape and the direction the CAMERA points as

    myshape.t1[3,0:3] - CAMERA.eye
    CAMERA.get_direction()

To find the angle between them as a rotation in the vertical (y) axis only, you could do something like

      import math
      v1 = myshape.tr1[3,0:3] - CAMERA.eye
      v2 = CAMERA.get_direction()
      a1 = math.atan2(v1[2], v1[0])
      a2 = math.atan2(v2[2], v2[0])
      sh_angle = math.degrees(a2 - a1)

Reply all
Reply to author
Forward
0 new messages