Skip to content

Commit

Permalink
fix: Initialize encoder_ticks_ in hw interface
Browse files Browse the repository at this point in the history
Initialize values in encoder_ticks_ member array of hardware interface
to zero because receiving meaningfultick values from the microcontroller
might take some time. Alleviates problems in #30
  • Loading branch information
fjp committed Mar 26, 2021
1 parent b05f9c0 commit 1232352
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion diffbot_base/include/diffbot_base/diffbot_hw_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ namespace diffbot_base

} // namespace

#endif // DIFFBOT_HW_INTERFACE_H
#endif // DIFFBOT_HW_INTERFACE_H
6 changes: 5 additions & 1 deletion diffbot_base/src/diffbot_hw_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ namespace diffbot_base

joint_velocity_commands_[i] = 0.0;

// Initialize encoder_ticks_ to zero because receiving meaningful
// tick values from the microcontroller might take some time
encoder_ticks_[i] = 0.0;

// Initialize the pid controllers for the motors using the robot namespace
std::string pid_namespace = "pid/" + motor_names[i];
ROS_INFO_STREAM("pid namespace: " << pid_namespace);
Expand Down Expand Up @@ -311,4 +315,4 @@ namespace diffbot_base
return angle * wheel_diameter_ / 2.0;
}

};
};

0 comments on commit 1232352

Please sign in to comment.