Skip to content

Commit 6688394

Browse files
goretkinv4hn
authored andcommitted
remove redundant/incorrect code.
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.
1 parent c6391de commit 6688394

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

robot_mechanism_controllers/include/robot_mechanism_controllers/joint_position_controller.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class JointPositionController : public pr2_controller_interface::Controller
113113

114114
private:
115115
int loop_count_;
116-
bool initialized_;
117116
pr2_mechanism_model::RobotState *robot_; /**< Pointer to robot structure. */
118117
control_toolbox::Pid pid_controller_; /**< Internal PID controller. */
119118
ros::Time last_time_; /**< Last time stamp of update. */

robot_mechanism_controllers/src/joint_position_controller.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace controller {
4444

4545
JointPositionController::JointPositionController()
4646
: joint_state_(NULL), command_(0),
47-
loop_count_(0), initialized_(false), robot_(NULL), last_time_(0)
47+
loop_count_(0), robot_(NULL), last_time_(0)
4848
{
4949
}
5050

@@ -141,12 +141,6 @@ void JointPositionController::update()
141141
assert(joint_state_->joint_);
142142
dt_= time - last_time_;
143143

144-
if (!initialized_)
145-
{
146-
initialized_ = true;
147-
command_ = joint_state_->position_;
148-
}
149-
150144
if(joint_state_->joint_->type == urdf::Joint::REVOLUTE)
151145
{
152146
angles::shortest_angular_distance_with_limits(

0 commit comments

Comments
 (0)