To ensure the safety of elderly people with a walking assistive device during the ground-stair transition, a system which could automatically transfer the walking mode between level walking and stair climbing was proposed. A road condition detection system with a RGB-D Camera and ultrasonic sensors was utilized in this system. The walking mode transformation is triggered by the detection of environment change. When far approach the stairs, the RGB-D Camera is responsible for the stair detection. The ultrasonic sensors are used in the near-approach of stairs and stair traversal. The ultrasonic sensors were mounted on the toe and heel to find the upwards and downwards stairs respectively. During stair traversal, if the ultrasonic sensors find the foot of the device is too closed to the edge of stairs, the target trajectory will be higher and the stride will be adjusted to prevent collisions. The Impedance control was introduced to let the device trace the predefined walking trajectories. In experiments, the device changed walking modes successfully when getting close the stairs. The results engaged in three subjects showed that the foot height was increased compared without assistance. Thus a huge potential can be expected that this system can solve the adaptability of walking assistive devices to different surroundings.