Nowadays robots are applied in many diversified industry fields, and even in our daily life. The structure of robots becomes more and more sophisticated, so designing and building such robots is not easy due to the growing complexity of the control systems structure. Therefore, many researchers focus on robot programming frameworks in order to simplify the process of designing and building robots. However, how to assemble agents, tasks and resources when building a robot is an important problem demanding efficient solution in the robot programming frameworks. In this paper, we present an approach, which can allocate the tasks of a robot to each agent according to the computational ability of agents, the execution time of tasks, and certain constraints, and can help manage all the resources (i.e., effectors and receptors) in the way which gives the structure with the least number of connections between agents. The allocation is proved to be Pareto Optimal.