How to make the Pantograph go up?

I want to achieve that when the Catenary is at the top the Panograph goes up automatically and when the Catenary goes down slowly the Panograph goes down flexibly the same way up, how can i do that?