0

I'm trying to use torque and braking to control the vehicle but the error "wb_motor_set_force() called with an invalid 'force' argument (NaN)." keeps appearing. Here are the code used:

Initialization

driver_->setGear(1);
driver_->step();
driver_->step();
driver_->step();

simulTime_ = 30;

breaking_ = false;
throttle_ = 0;
breaking_ = 0;

Control application

if(type_ == BREAK){
    if(!type_){
        type_ = true;
        driver_->setThrottle(0);
    }
    driver_->setBrakeIntensity(breaking_);
}
else if(type_ == ACCELERATE){
    if(type_){
        type_ = false;
        driver_->setBrakeIntensity(0);
    }
    driver_->setThrottle(throttle_);
}

driver_->setSteeringAngle(phi_);
driver_->step();
simulTime_ += simulStep_;

Thanks!

Nelson
  • 67
  • 5

1 Answers1

2

I tried to reproduce your issue with a very simple controller similar to yours:

#include <webots/vehicle/Driver.hpp>

using namespace webots;

int main(int argc, char **argv) {
  Driver *driver = new Driver();

  driver->setGear(1);

  // main loop
  while (driver->step() != -1) {
    driver->setThrottle(0.1);
    driver->setBrakeIntensity(0.0);
    driver->setSteeringAngle(0.1);
  }

  delete driver;
  return 0;
}

But it is working fine, I don't have any warning about "wb_motor_set_force() called with an invalid 'force' argument (NaN).". Can you try my example and let me know if this works for you too? If it does can you change my example (as less as possible) so that it reproduce your issue?

David Mansolino
  • 1,713
  • 7
  • 13
  • 1
    I don't know why but your code works, but not mine (which is a bit more complicated than the piece I shown). I'm gonna try to figure it out why. Thanks for the help! – Nelson Feb 03 '20 at 07:28