This paper proposes a task allocation model to adjust the number of working robots autonomously in a swarm of foraging robots. In swarm foraging, the traffic congestion in foraging area and the physical interference between robots can decrease the swarm performance significantly. We introduce the concept of traffic flow density for the first time which can be used to reflect the traffic condition in the foraging area. The amount of obstacle avoidance denotes the number of times physical interference generated in swarm foraging. The traffic flow density and the amount of obstacle avoidance together adjust the value of the threshold. In the proposed response threshold sigmoid model (RTSM), the individual robot can determine autonomously whether to forage or not on the basis of the threshold and the external stimulus and the swarm system can complete the expected foraging task. Simulation experiments are carried out with the aim of evaluating the performance of the proposed method. Several performance measures are introduced to analyze the experimental results and compare to adaptive response threshold model (ARTM). Experimental results verify that the RTSM improves foraging efficiency and decreases the physical interference.