Skip to content

Commit

Permalink
remove redundant/incorrect code.
Browse files Browse the repository at this point in the history
there is no need for an `initialized_` flag, because the controller manager
will call `starting` to indicate the first iteration of a control cycle.

The controller already does the correct thing in `starting`. If instead the
code in `starting` were removed, and the `initialized_` flag kept, then this
position controller would (incorrectly) jump to the previous set point if it is
stopped and started (for example, if you hit and release the run-stop), since
the `initialized_` flag was only being cleared in the constructor.
  • Loading branch information
goretkin authored and v4hn committed Aug 10, 2022
1 parent 212ee08 commit 5548003
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class JointPositionController : public pr2_controller_interface::Controller

private:
int loop_count_;
bool initialized_;
pr2_mechanism_model::RobotState *robot_; /**< Pointer to robot structure. */
control_toolbox::Pid pid_controller_; /**< Internal PID controller. */
ros::Time last_time_; /**< Last time stamp of update. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace controller {

JointPositionController::JointPositionController()
: joint_state_(NULL), command_(0),
loop_count_(0), initialized_(false), robot_(NULL), last_time_(0)
loop_count_(0), robot_(NULL), last_time_(0)
{
}

Expand Down Expand Up @@ -141,12 +141,6 @@ void JointPositionController::update()
assert(joint_state_->joint_);
dt_= time - last_time_;

if (!initialized_)
{
initialized_ = true;
command_ = joint_state_->position_;
}

if(joint_state_->joint_->type == urdf::Joint::REVOLUTE)
{
angles::shortest_angular_distance_with_limits(
Expand Down

0 comments on commit 5548003

Please sign in to comment.