Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. int main() {
  2. wb_robot_init();
  3.  
  4. WbDeviceTag motor = wb_robot_get_device("my_motor");
  5.  
  6. double F = 2.0; // frequency 2 Hz
  7. double t = 0.0; // elapsed simulation time
  8.  
  9. while (wb_robot_step(TIME_STEP) != -1) {
  10. double pos = sin(t * 2.0 * M_PI * F);
  11. wb_motor_set_position(motor, pos);
  12. t += (double)TIME_STEP / 1000.0;
  13. }
  14.  
  15. wb_robot_cleanup();
  16.  
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement