plusone-robotics / moveit_simple

A wrapper around MoveIt that enables more traditional industrial robot programming.
Apache License 2.0
15 stars 12 forks source link

Checking return of addTrajPoint and execute methods makes for ugly code #7

Closed shaun-edwards closed 7 years ago

shaun-edwards commented 7 years ago

Because addTrajPoint and execute return true on success, otherwise false, handling failures can make for ugly code:

if( robot_.addTrajPoint(place_traj, offset, frame,         0.2, "dp_offset") &&
     robot_.addTrajPoint(place_traj, "wp_pick_approach",   0.4) &&
     robot_.addTrajPoint(place_traj, "wp_place_approach",  * 1.2) &&
     robot_.addTrajPoint(place_traj, "wp_place",          1.6))
  {
    if( robot_.execute(place_traj) )
       ...

  }

Perhaps we should consider changing to throwing exceptions.

shaun-edwards commented 7 years ago

@geoffreychiou, could you take a look at this.

shaun-edwards commented 7 years ago

@nsnitish, please take a look at this. Exceptions are and obvious solution to this. I don't believe any of the standard exceptions apply, but you should probably inherit from std::runtime_error. See here for some more background.

shaun-edwards commented 7 years ago

This has been addressed in PR #18