By Bolun Dai | Jan 4th 2021
HouseExpo
Before we do anything, we need to first figure out the coordinate system used in HouseExpo. For any map, the origin \((0, 0)\) is at the upper left corner. If we use a Cartesian coordinate system as comparison, the positive \(x\)-axis in HouseExpo is along the negative \(y\)-axis, and the positive \(y\)-axis co-aligns with the positive \(x\)-axis of the Cartesian coordinates. As for the orientation, going from the positive \(x\)-axis in the Cartesian coordinates to the negative \(x\)-axis counterclockwise is going from \(0^\circ\) to \(180^\circ\); if going clockwise, then it is from \(0^\circ\) to \(-180^\circ\) in HouseExpo.
The following can be dissected into two steps: centering the agent and rotating the map. To do this, we need to know the size of the background canvas \((h, w)\), the position of the agent in the global map \((p_x, p_y)\), and the size of the global map \((g_x, g_y)\). Then we can assign the corresponding cells in the canvas to have values equal to those in the global map.
The next step is to rotate the canvas. If the current orientation of the robot is \(+\theta\), then we would need to rotate the canvas by \(-\theta\). After this, we have the rotated image where the robot is heading right; if we want the robot to face up, we would need to rotate the canvas by \(90^\circ\). We use the following image to illustrate this process.