Week 13: Interface and Application Programming

xdd44, Dec. 4, 2024

I have done tons of interface development before, so I decided to just do a simple interface and spend time make my toy (see beginning of last week) work.

My idea is to display a digital twin of the toy's platform, and has it tilt reversely so that its orientation appears fixed in real world space.

The interface tilted

This implementation was a bit tricky. It is actually harder to place the camera above the object facing down in application space, since Unity's quaternion formatted rotation would get confused when an object (the camera in our case) is rotated over an axis. There are functions such as void LookAt(Transform target, Vector3 worldUp = Vector3.up); but it's hard to calculate which direction is actually "up".

The recording below shows if simply use LookAt, the camera will keep bottom of view downward in Unity space, resulting in the object appear rotating when camera passes right above.

Simply use LookAt() function resulting in wrong tilting.

In the end I fixed my camera facing horizontally, standed the platform up, and applied tilting from accelerometer to the platform.

The actual setup


I continued to design my physical framework to hold the framework. I incorporated two stepper motors to control the two axes, and two corresponding potentiometers to read the current tilting angle. I WRONGLY chose acrylic sheet as the material to build it.

The digital model of my framework

It turned out I overestimated the strength of acrylic and made everything too thin. And I broke it just when I started testing the motors.

The only photo of my product

Anyhow, I also discovered two mistake of my design: 1. The motor doesn't have enough torque to precisely control the platform. 2. The weight of the motor made the platform really unbalanced, so the outer motor can't even keep it steadily flat. Therefore, I have to spare one more week for this project.