I am trying to add a distance sensor to a kuka robot in webots software KUKA robot that has no field called children but I added the distance sensor in bodyslot field now the sensor is reading nan all the time
#include <webots/keyboard.h>
#include <webots/robot.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <webots/distance_sensor.h>
#define TIME_STEP 32
int main(int argc, char **argv) {
wb_robot_init();
//////////////////////////////
WbDeviceTag ps[1];
char ps_names[1][3] = {"DS"};
ps[0] = wb_robot_get_device(ps_names[0]);
wb_distance_sensor_enable(ps[0], TIME_STEP);
////////////////////////////////
// read sensors outputs
double ps_values;
ps_values = wb_distance_sensor_get_value(ps[0]);
//////////////////////////////////////////////////////////
while (true) {
step();
printf ("\n %f \n", ps_values);
//while (ps_values > 80){
base_forwards_increment();
//}
// base_backwards_increment();
}
wb_robot_cleanup();
return 0;
}
enter image description here To find a way to add a distance sensor to kuka robot