Story related, can't be missed.
When you get to the part where there are carts, the end scenario must be the red lights on the carts are both facing away from the sub on the red track in the middle. Once they are both like that, tell Trip to move things forward and the sub will move on a now cleared path. The level will end when you pull Pigsy back up to the sub.
Solution to cart puzzle: Pull the first switch you get to. Jump on the cart and move them forward holding and using the forward command. Jump the cap to the next cart, and command to reverse. Get out and press the level on the new side, and get back on. Now command to move forward. Jump on the pipe to your right and use this route to get back to the first lever. Get the first cart to face the dead end and command to move forward. Both carts will go to their dead ends and the sub will be able to move forward.