The invention relates to a rotary motion and reciprocating motion converting device (20) which comprises pistons (72, 74, 76, 78), wherein one end of each piston rods (62, 64) is connected with the pistons (72, 74, 76, 78); a shell (25) is installed on a base seat (11); a side wall (28) of the shell (25) is provided with a bearing seat (5); a transmission shaft (6) is installed in the bearing seat (5); the transmission shaft (6) is provided with transmission wheels (15, 17); the edge parts of the transmission wheels (15, 17) are provided with column pins (7, 71) extending out axially; a first gear (10) and a second gear (14) which can rotate relative to the transmission shaft (6) are installed close to the transmission wheels (15, 17); the first gear (10) and a first rack (2) are meshed mutually; the second gear (14) and a second rack (22) are meshed mutually; the first rack (2) and the second rack (22) are respectively positioned at two sides of the transmission shaft (6); connecting plates (90, 91) are connected with the end parts of the first rack (2) and the second rack (22); the connecting plates (90,91) are connected with other ends of the piston rods (62, 64); tooth-free parts of the first gear (10) and the second gear (14) are respectively provided with pin grooves (9, 21); the pin grooves (9, 21) are internally provided with sliding blocks (32, 42) which are matched with the column pins (7, 71); and the restoration springs (12, 121) are arranged below the sliding blocks (32, 42). Thus the conversion between the rotary motion and the reciprocating motion is realized.