There a a few ways to achieve this. Check out these threads:
I’d recommend using the RTDE interface, but you are not limited to solely this method.