Skip to content

Commit

Permalink
Laser visualization update rate differs from distance sensor rays cyb…
Browse files Browse the repository at this point in the history
…erbotics#5492 (cyberbotics#5801)

* Resolve cyberbotics#5492: Updated controller time step - laser_pointer.c

* Resolve cyberbotics#5492: Updated controller time step to robot basic time step - laser_pointer.c

* Resolve cyberbotics#5492: Updated controller time step - laser_pointer.c

* Resolve cyberbotics#5492: Clang format correction

---------

Co-authored-by: Stefania Pedrazzi <[email protected]>
  • Loading branch information
Chandan-Bharadwaj and stefaniapedrazzi authored Jan 31, 2023
1 parent 217a947 commit 045000f
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@
#include <webots/motor.h>
#include <webots/robot.h>

#define TIME_STEP 64

int main() {
// initialize webots stuff
wb_robot_init();
const int time_step = wb_robot_get_basic_time_step();

// get camera tag and initialize
WbDeviceTag camera = wb_robot_get_device("camera");
wb_camera_enable(camera, TIME_STEP);
wb_camera_enable(camera, time_step);

WbDeviceTag laser0 = wb_robot_get_device("laser0");
WbDeviceTag laser1 = wb_robot_get_device("laser1");
wb_distance_sensor_enable(laser0, TIME_STEP);
wb_distance_sensor_enable(laser1, TIME_STEP);
wb_distance_sensor_enable(laser0, time_step);
wb_distance_sensor_enable(laser1, time_step);

// get a handler to the motors and set target position to infinity (speed control).
WbDeviceTag left_motor = wb_robot_get_device("left wheel motor");
Expand All @@ -49,7 +48,7 @@ int main() {
wb_motor_set_velocity(right_motor, 0.0);

// control loop
while (wb_robot_step(TIME_STEP) != -1) {
while (wb_robot_step(time_step) != -1) {
// update image
(void)wb_camera_get_image(camera);

Expand Down

0 comments on commit 045000f

Please sign in to comment.