Advertisement
Ostu

Untitled

Jun 1st, 2021
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.65 KB | None | 0 0
  1. TIME_STEP = 64;
  2.  
  3. % get and enable devices, e.g.:
  4. %  camera = wb_robot_get_device('camera');
  5. %  wb_camera_enable(camera, TIME_STEP);
  6.  
  7. motor1 = wb_robot_get_device( 'left wheel motor' );
  8. motor2 = wb_robot_get_device( 'right wheel motor' );
  9.  
  10. wb_motor_set_position( motor1, inf );
  11. wb_motor_set_position( motor2, inf );
  12.  
  13. while wb_robot_step(TIME_STEP) ~= -1
  14.  
  15.   v = 0;
  16.   w = 1;
  17.  
  18.   v1 = 0.4878*v + 1.2683*w;
  19.   v2 = 0.4878*v - 1.2683*w;
  20.  
  21.   wb_motor_set_velocity( motor1, v1 )
  22.   wb_motor_set_velocity( motor2, v2 )
  23.  
  24.   % read the sensors, e.g.:
  25.   %  rgb = wb_camera_get_image(camera);
  26.  
  27.   drawnow;
  28.  
  29.   wb_console_print( 'abcd', WB_STDOUT );
  30.  
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement