The control of a robot is optimized to improve its energy efficiency and stability in a geometrically complex environment. For this purpose, analysis is performed on the dynamic modeling of a multi-body robot that can transition its position on corners where horizontal ground and a vertical wall intersect. The robot consists of three bodies that can be attached to the wall by permanent magnetic adhesion and connected by links with two types of compliant joints: a passive type with a torsion spring and an active type with a torque-controlled motor. A dynamics model is derived using the Lagrangian formulation, and investigated in the case of internal corner. Difficulties in the analysis of dynamics for this wall-climbing robot came from how to manage external forces. The external forces acting on the wallclimbing robot result from the wall and the magnets, which change the acting points of the forces. Experiments were conducted to determine the magnetic force with respect to distance. Simulation was then performed to verify the dynamic model. The obtained dynamic model can offer a competent tool for the design and control of the autonomous wall-climbing robot, which can be used for the inspection of heavy-industry buildings, and oil tanks where the geometrically horizontal surface and the vertical wall intersect.