Skip to content

Commit 2dbdbac

Browse files
committed
added a gain parameter for position control for UR5e
1 parent 5f84d8d commit 2dbdbac

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

moveit_ros/moveit_servo/config/servo_parameters.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,14 @@ servo:
340340
bounds<>: [0.0, 1.0]
341341
}
342342
}
343+
344+
position_control_gain: {
345+
type: double,
346+
default_value: 1.0,
347+
description: "Gain multiplier applied to joint position deltas before publishing. \
348+
Useful when commanding a forward_position_controller where larger steps \
349+
are needed to achieve the desired Cartesian velocity.",
350+
validation: {
351+
gt<>: 0.0
352+
}
353+
}

moveit_ros/moveit_servo/src/servo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,10 @@ Eigen::VectorXd Servo::jointDeltaFromCommand(const ServoInput& command, const mo
463463
servo_status_ = StatusCode::INVALID;
464464
RCLCPP_WARN_STREAM(logger_, "Incoming servo command type does not match known command types.");
465465
}
466+
// if we are in forward_position_controller, multiply the joint_position_deltas by 4
466467

468+
joint_position_deltas *= servo_params_.position_control_gain;
469+
467470
return joint_position_deltas;
468471
}
469472

@@ -521,7 +524,7 @@ KinematicState Servo::getNextJointState(const moveit::core::RobotStatePtr& robot
521524
target_state.velocities *= joint_velocity_limit_scale;
522525

523526
// Adjust joint position based on scaled down velocity
524-
target_state.positions = current_state.positions + (target_state.velocities * servo_params_.publish_period) * 20;
527+
target_state.positions = current_state.positions + (target_state.velocities * servo_params_.publish_period);
525528

526529
// Apply collision scaling to the joint position delta
527530
target_state.positions =

moveit_ros/moveit_servo/src/servo_node.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void ServoNode::servoLoop()
367367
// if all joint_cmd_rolling_window_ is empty or all commands in it are outdated, use current robot state
368368
joint_cmd_rolling_window_.clear();
369369
current_state = servo_->getCurrentRobotState(false /* block for current robot state */);
370-
current_state.velocities *= 0.0;
370+
// current_state.velocities *= 0.0;
371371
}
372372

373373
// update robot state values
@@ -376,7 +376,7 @@ void ServoNode::servoLoop()
376376

377377
next_joint_state = std::nullopt;
378378
const CommandType expected_type = servo_->getCommandType();
379-
379+
380380
if (expected_type == CommandType::JOINT_JOG && new_joint_jog_msg_)
381381
{
382382
next_joint_state = processJointJogCommand(robot_state);

0 commit comments

Comments
 (0)