# SambotII: A New Self-Assembly Modular Robot Platform Based on Sambot
## 4 Software Architecture and Task Functions of SambottII  
A hierarchical architecture is proposed for the software system. As shown in Figure 7, the hardware and software are decoupled from each other in the architecture. It improves the software reusability and simplifies programming by using the uniform abstract interfaces between different layers and programs. \begin{table}
\begin{tabular}{c c} \hline \hline
**Components** & **Description** \\ \hline Processor & Dual-core, dual-threaded Intel Atom CPU at 500 MHz with 1 MB cache. \\  & Supporting SIMD SSE2, SSE3, SSE4.1/4.2 \\ RAM memory & 1 GB \\ Storage & 4 GB eMMC \\ Wireless & 2.4 and 5 GHz IEEE 802.11a/b/g/n \\ Bluetooth & BT4.0 \\ USB & USB2.0 OTG \\ Sizes & \(35.5\times 25.0\times 3.9\) mm \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Features of the Intel Edison CPU module. Figure 7: Software architecture. There are five main layers in the software system: (1) hardware abstract layer; (2) module abstract layer; (3) operation layer; (4) behavior layer; and, (5) task layer. Different layer consists of different blocks, which are designed for particular functions and offer implementation-irrelevant interfaces to upper layers. The hardware abstract layer acts as an abstract interconnection between the hardware and the software. All the control details of the hardware are hidden in this layer. For instance, the \"motor controller abstraction class\" controls four motors and offers an interface for upper layer to adjust motor speed. The \"encoder accessor abstraction class\" processes pulse signals generated by the encoder and converts them into velocity and positional data. The I/O class reads and sets GPIO through I/O chip. The \"IMU class\" reads the rotation and acceleration data from IMU. These four classes are built in MCU to meet real-time requirements. Besides, the \"image class\" captures images from the camera by utilizing the OpenCV library in Intel Edison module. The module abstract layer offers higher level module abstractions by integrating the blocks of the hardware abstract layer into modules. For instance, the \"motor closed-loop control class\" reads velocity and positional data from the \"encoder accessor abstraction class\" and sends speed commands to the \"motor controller abstraction class\". With the inner control algorithms, it can control speed and position, making it easier for the operation layer to control robot's motion, and so does the \"motor limit control class\". The \"attitude algorithm class\" reads data from the \"IMU class\" and calculates the orientation after data filtering and fusion. Finally, the Wi-Fi module is used to establish the wireless network environment for data communication. The operation layer contains operation blocks, which control the specific operations of the robot. For example, the \"wheels motion control block\" in the operation layer combines the \"motor closed-loop control block\" and the \"attitude algorithm block\", and so it can control the movement operations of the robot. In this way, we can just focus on designing the behavior and task algorithms, rather than the details of motor driving, control, or wheels movement. Similarly, the blocks, \"neck rotation\", \"hooks open close\", \"laser control\", and \"LED control\", are used to control the corresponding operations of the robot, respectively. The \"image info extraction block\" is designed to extract the useful information we care about from images. Through the \"data stream communication block\", robots can coordinate with each other by exchanging information and commands. The behavior layer is a kind of command-level abstraction designed for executing practical behaviors. A behavior can utilize operation blocks and other behavior blocks when executing.