Skip to content

Commit

Permalink
Fix flaky transmission_interface tests by making them deterministic. (#…
Browse files Browse the repository at this point in the history
…1665)

(cherry picked from commit ace8416)

# Conflicts:
#	transmission_interface/test/random_generator_utils.hpp
  • Loading branch information
sgmurray authored and mergify[bot] committed Aug 13, 2024
1 parent 0af922d commit 93268e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ inline void FourBarLinkageTransmission::actuator_to_joint()

joint_eff[0].set_value(jr[0] * act_eff[0].get_value() * ar[0]);
joint_eff[1].set_value(
jr[1] * (act_eff[1].get_value() * ar[1] - act_eff[0].get_value() * ar[0] * jr[0]));
jr[1] * (act_eff[1].get_value() * ar[1] - jr[0] * act_eff[0].get_value() * ar[0]));
}
}

Expand Down
8 changes: 7 additions & 1 deletion transmission_interface/test/random_generator_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ using std::vector;
/// \brief Generator of pseudo-random double in the range [min_val, max_val].
// NOTE: Based on example code available at:
// http://stackoverflow.com/questions/2860673/initializing-a-c-vector-to-random-values-fast
// Use a user specified seed instead of system time for deterministic tests
struct RandomDoubleGenerator
{
public:
RandomDoubleGenerator(double min_val, double max_val) : min_val_(min_val), max_val_(max_val)
RandomDoubleGenerator(double min_val, double max_val, unsigned int seed = 1234)
: min_val_(min_val), max_val_(max_val)
{
<<<<<<< HEAD
srand(time(nullptr));
=======
srand(seed);
>>>>>>> ace8416 (Fix flaky transmission_interface tests by making them deterministic. (#1665))
}
double operator()()
{
Expand Down

0 comments on commit 93268e4

Please sign in to comment.