Before downhole application, the pre-development test of the main controller of the rotary steerable tool often needs to be verified repeatedly, and in the actual development test, there may be test conditions that cannot be covered by the actual attitude sensor test process, as well as device damage due to operation errors, so that the testing effect can not meet the actual test and development needs. Because of the above problems, this paper studies the virtual while-drilling attitude sensor based on SP6000. According to the design, this method compiles and downloads the simulation model into the hardware-in-loop simulation box. Then, connect it with the main controller through the I/O interface, running the simulation attitude sensor model, and output attitude signals to the main controller in real-time. Finally, the attitude parameters calculated by the main controller are compared with the hardware in loop simulation cabinet output of the real-time running attitude sensor model to judge the experiment's success.