|
21 | 21 | * |
22 | 22 | * \author Lovro Ivanov [email protected] |
23 | 23 | * \author Andy Zelenak [email protected] |
| 24 | + * \author Marvin Große Besselmann [email protected] |
24 | 25 | * \date 2020-11-9 |
25 | 26 | * |
26 | 27 | */ |
@@ -49,6 +50,10 @@ hardware_interface::return_type URPositionHardwareInterface::configure(const Har |
49 | 50 | urcl_tcp_pose_ = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } }; |
50 | 51 | urcl_position_commands_ = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } }; |
51 | 52 | urcl_velocity_commands_ = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } }; |
| 53 | + runtime_state_ = static_cast<uint32_t>(rtde::RUNTIME_STATE::STOPPED); |
| 54 | + pausing_state_ = PausingState::RUNNING; |
| 55 | + pausing_ramp_up_increment_ = 0.01; |
| 56 | + controllers_initialized_ = false; |
52 | 57 |
|
53 | 58 | for (const hardware_interface::ComponentInfo& joint : info_.joints) |
54 | 59 | { |
@@ -376,6 +381,41 @@ return_type URPositionHardwareInterface::read() |
376 | 381 |
|
377 | 382 | // TODO logic for sending other stuff to higher level interface |
378 | 383 |
|
| 384 | + // pausing state follows runtime state when pausing |
| 385 | + if (runtime_state_ == static_cast<uint32_t>(rtde::RUNTIME_STATE::PAUSED)) |
| 386 | + { |
| 387 | + pausing_state_ = PausingState::PAUSED; |
| 388 | + } |
| 389 | + // When the robot resumed program execution and pausing state was PAUSED, we enter RAMPUP |
| 390 | + else if (runtime_state_ == static_cast<uint32_t>(rtde::RUNTIME_STATE::PLAYING) && |
| 391 | + pausing_state_ == PausingState::PAUSED) |
| 392 | + { |
| 393 | + speed_scaling_combined_ = 0.0; |
| 394 | + pausing_state_ = PausingState::RAMPUP; |
| 395 | + } |
| 396 | + |
| 397 | + if (pausing_state_ == PausingState::RAMPUP) |
| 398 | + { |
| 399 | + double speed_scaling_ramp = speed_scaling_combined_ + pausing_ramp_up_increment_; |
| 400 | + speed_scaling_combined_ = std::min(speed_scaling_ramp, speed_scaling_ * target_speed_fraction_); |
| 401 | + |
| 402 | + if (speed_scaling_ramp > speed_scaling_ * target_speed_fraction_) |
| 403 | + { |
| 404 | + pausing_state_ = PausingState::RUNNING; |
| 405 | + } |
| 406 | + } |
| 407 | + else if (runtime_state_ == static_cast<uint32_t>(rtde::RUNTIME_STATE::RESUMING)) |
| 408 | + { |
| 409 | + // We have to keep speed scaling on ROS side at 0 during RESUMING to prevent controllers from |
| 410 | + // continuing to interpolate |
| 411 | + speed_scaling_combined_ = 0.0; |
| 412 | + } |
| 413 | + else |
| 414 | + { |
| 415 | + // Normal case |
| 416 | + speed_scaling_combined_ = speed_scaling_ * target_speed_fraction_; |
| 417 | + } |
| 418 | + |
379 | 419 | return return_type::OK; |
380 | 420 | } |
381 | 421 |
|
|
0 commit comments