Force_mode() with changing desired force

Hi!

I am using UR5 + FT300 + CB3.1, which enabled external sensor feed to force_mode(). I am streaming UR Scripts using ROS driver ur_modern_driver, basically it opens a socket at UR controller, and simply forward UR Scripts to UR5.

I am forwarding the script “force_mode( p[0.0,0.0,0.0,0.0,0.0,0.0], [1.0,1.0,1.0,1.0,1.0,1.0], [0.0, 0.0, 50.0, 0.0, 0.0, 0.0], 2, [1005.0, 1005.0, 1000.0, 1005.0, 1005.0, 1005.0])” to UR5, which means 50N in Z axis, the robot does not do anything.

I understand there is another similar question Real time force_mode, that I should forward an entire program rather than just a line.

My question is :

  1. how can I change the desired force on the fly, say at 1s I want Fz = 50N , at 1.25s I want Fz=-25N etc… can I do this with the program that mentioned in the link above?
  2. what would be the frequency to stream this force command.

Thanks so much!

Maybe the article on Dynamic Force control can give an idea, but calling the force_mode() command from a Thread may be a good option.