First: use code tags for code and not quote tags!
The UNO doesn't have a Serial2:
lidar.begin(Serial2);
So either your wiring diagram is wrong (you're not using a UNO), your code does not compile or you've chosen the wrong board in the IDE (in which case it won't upload).
I connect it to the Arduino it does not work.
This is a complete unusable message. Do you get an error? Does the motor not turn? Do you have power on the device?