@@ -361,8 +361,10 @@ bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_
361361{
362362 if (robot_version_.major < 5 )
363363 {
364- URCL_LOG_ERROR (" Force mode gain scaling factor cannot be set on a CB3 robot." );
365- return false ;
364+ std::stringstream ss;
365+ ss << " Force mode gain scaling factor cannot be set on a CB3 robot." ;
366+ URCL_LOG_ERROR (ss.str ().c_str ());
367+ throw std::invalid_argument (ss.str ().c_str ());
366368 }
367369 // Test that the type is either 1, 2 or 3.
368370 switch (type)
@@ -383,21 +385,27 @@ bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_
383385 {
384386 if (selection_vector[i] > 1 )
385387 {
386- URCL_LOG_ERROR (" The selection vector should only consist of 0's and 1's" );
387- return false ;
388+ std::stringstream ss;
389+ ss << " The selection vector should only consist of 0's and 1's" ;
390+ URCL_LOG_ERROR (ss.str ().c_str ());
391+ throw std::invalid_argument (ss.str ().c_str ());
388392 }
389393 }
390394
391395 if (damping_factor > 1 || damping_factor < 0 )
392396 {
393- URCL_LOG_ERROR (" The force mode damping factor should be between 0 and 1, both inclusive." );
394- return false ;
397+ std::stringstream ss;
398+ ss << " The force mode damping factor should be between 0 and 1, both inclusive." ;
399+ URCL_LOG_ERROR (ss.str ().c_str ());
400+ throw std::invalid_argument (ss.str ().c_str ());
395401 }
396402
397403 if (gain_scaling_factor > 2 || gain_scaling_factor < 0 )
398404 {
399- URCL_LOG_ERROR (" The force mode gain scaling factor should be between 0 and 2, both inclusive." );
400- return false ;
405+ std::stringstream ss;
406+ ss << " The force mode gain scaling factor should be between 0 and 2, both inclusive." ;
407+ URCL_LOG_ERROR (ss.str ().c_str ());
408+ throw std::invalid_argument (ss.str ().c_str ());
401409 }
402410
403411 if (script_command_interface_->clientConnected ())
@@ -419,9 +427,10 @@ bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_
419427{
420428 if (robot_version_.major >= 5 )
421429 {
422- URCL_LOG_ERROR (" You should also specify a force mode gain scaling factor to activate force mode on a e-series "
423- " robot." );
424- return false ;
430+ std::stringstream ss;
431+ ss << " You should also specify a force mode gain scaling factor to activate force mode on an e-series robot." ;
432+ URCL_LOG_ERROR (ss.str ().c_str ());
433+ throw std::invalid_argument (ss.str ().c_str ());
425434 }
426435 // Test that the type is either 1, 2 or 3.
427436 switch (type)
@@ -442,15 +451,19 @@ bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_
442451 {
443452 if (selection_vector[i] > 1 )
444453 {
445- URCL_LOG_ERROR (" The selection vector should only consist of 0's and 1's" );
446- return false ;
454+ std::stringstream ss;
455+ ss << " The selection vector should only consist of 0's and 1's" ;
456+ URCL_LOG_ERROR (ss.str ().c_str ());
457+ throw std::invalid_argument (ss.str ().c_str ());
447458 }
448459 }
449460
450461 if (damping_factor > 1 || damping_factor < 0 )
451462 {
452- URCL_LOG_ERROR (" The force mode damping factor should be between 0 and 1, both inclusive." );
453- return false ;
463+ std::stringstream ss;
464+ ss << " The force mode damping factor should be between 0 and 1, both inclusive." ;
465+ URCL_LOG_ERROR (ss.str ().c_str ());
466+ throw std::invalid_argument (ss.str ().c_str ());
454467 }
455468
456469 if (script_command_interface_->clientConnected ())
0 commit comments