Programming a virtual robot
We will first detect our robot's orientation; it would be useful to show this as a 3D robot model. This part builds upon the Representing coordinate and rotation systems section in Chapter 12, IMU Programming with Python. In this section, we will construct a simple model of our robot in VPython.
Modeling the robot in VPython
We'll use shapes, known as primitives, to model the robot. They have a position, rotation, size, and color. The height-and-width parameters match the VPython-world coordinate system (see Figure 12.14 – The robot body coordinate system in Chapter 12, IMU Programming with Python), so we must rotate things to match the robot body coordinate system.
First, we need to collect some robot measurements. The following diagram shows where they are. Once the major measurements are made, estimates can be used for smaller measurements: