Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jog_arm] a ROS service to enable task redundancy #1855

Merged
merged 11 commits into from
Feb 19, 2020
Merged

[jog_arm] a ROS service to enable task redundancy #1855

merged 11 commits into from
Feb 19, 2020

Conversation

AndyZe
Copy link
Member

@AndyZe AndyZe commented Jan 22, 2020

Add a ROS service to turn redundancy on/off in specific dimensions. For example, maybe you could allow wrist rotation by drift_x_rotation == true. For now, the reference frame is the jogging command frame.

This depends on this moveit_msgs PR

Here are 2 gif's starting from a singular position, without and with allowing drift respectively. It's trying to move in the world Y-direction. The first gif shows it stuck. The second gif moves past the singularity, no problem.
no_drift_allowed

with_drift_allowed

@AndyZe AndyZe changed the title [jog_arm] a ROS server to enable task redundancy [jog_arm] a ROS service to enable task redundancy Jan 22, 2020
@AndyZe
Copy link
Member Author

AndyZe commented Jan 27, 2020

CI tests are failing because this PR to moveit_msgs hasn't been merged yet. moveit/moveit_msgs#63

@codecov-io
Copy link

codecov-io commented Feb 11, 2020

Codecov Report

Merging #1855 into master will increase coverage by 0.02%.
The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1855      +/-   ##
==========================================
+ Coverage   50.26%   50.29%   +0.02%     
==========================================
  Files         313      313              
  Lines       24623    24652      +29     
==========================================
+ Hits        12377    12398      +21     
- Misses      12246    12254       +8
Impacted Files Coverage Δ
...veit_jog_arm/include/moveit_jog_arm/jog_arm_data.h 100% <ø> (ø) ⬆️
.../moveit_jog_arm/include/moveit_jog_arm/jog_calcs.h 100% <ø> (ø) ⬆️
...og_arm/include/moveit_jog_arm/jog_interface_base.h 100% <ø> (ø) ⬆️
...rimental/moveit_jog_arm/src/jog_interface_base.cpp 84.76% <100%> (+1.42%) ⬆️
...erimental/moveit_jog_arm/src/jog_ros_interface.cpp 85.18% <100%> (+0.37%) ⬆️
...veit_experimental/moveit_jog_arm/src/jog_calcs.cpp 70.5% <23.07%> (-2.29%) ⬇️
...xperimental/moveit_jog_arm/src/low_pass_filter.cpp 95.45% <0%> (-4.55%) ⬇️
moveit_core/planning_scene/src/planning_scene.cpp 46.13% <0%> (+0.14%) ⬆️
...erimental/moveit_jog_arm/src/jog_cpp_interface.cpp 12.04% <0%> (+0.14%) ⬆️
...ccupancy_map_monitor/src/occupancy_map_monitor.cpp 30.61% <0%> (+0.95%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b56cd6...576df8e. Read the comment docs.

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Please fix the test and then lgtm.

It only fails on CI, fine locally
Copy link
Contributor

@mlautman mlautman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really close to ready. Could almost be merged as is. Some minor feedback then ping me for an approval

@@ -79,6 +79,10 @@ struct JogArmShared

// The transform from the MoveIt planning frame to robot_link_command_frame
Eigen::Isometry3d tf_moveit_to_cmd_frame;

// True -> allow drift in this dimension. In the command frame. [x, y, z, roll, pitch, yaw]
std::atomic_bool drift_dimensions[6] = { ATOMIC_VAR_INIT(false), ATOMIC_VAR_INIT(false), ATOMIC_VAR_INIT(false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use c-style arrays rather than a std::array<std::atomic_bool, 6>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not so easy to initialize a vector of std::atomic's to default values. It took me a lot of stackexchange browsing to figure this out. Something like this doesn't work:

std::vector<std::atomic_bool> test = {ATOMIC_VAR_INIT(false), ATOMIC_VAR_INIT(false)};

The compiler error is:

error: use of deleted function ‘std::atomic<bool>::atomic(const std::atomic<bool>&)’ { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }

Also, it's always going to have a length of 6, so you don't need a lot of the functionality of a std::vector.

// Work backwards through the 6-vector so indices don't get out of order
for (auto dimension = jacobian_.rows(); dimension >= 0; --dimension)
{
if (shared_variables.drift_dimensions[dimension] && jacobian_.rows() > 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check jacobian_.rows() > 1 once outside the loop instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea but I don't think so, because you might be removing a row in every iteration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I guess I could move it out if I counted the number of true's in shared_variables.drift_dimensions. Meh, that might be more trouble than it's worth

* @param delta_x Vector of Cartesian delta commands, should be 6-long.
* @param row_to_remove Dimension that will be allowed to drift, e.g. row_to_remove = 2 allows z-translation drift.
*/
void removeDimension(Eigen::MatrixXd& matrix, Eigen::VectorXd& delta_x, unsigned int row_to_remove);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be two different methods:

Suggested change
void removeDimension(Eigen::MatrixXd& matrix, Eigen::VectorXd& delta_x, unsigned int row_to_remove);
void removeDimension(Eigen::MatrixXd& matrix, unsigned int row_to_remove);
void removeDimension(Eigen::VectorXd& delta_x, unsigned int index_to_remove);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of 2 separate methods because:

  • you need to call both methods or there will be a size mismatch when you try to multiply them

  • it's a little bit more efficient this way (same for-loop)

@mlautman mlautman merged commit 2686359 into moveit:master Feb 19, 2020
@AndyZe AndyZe deleted the allow_jog_drift branch February 27, 2020 19:47
@tylerjw tylerjw mentioned this pull request May 8, 2020
20 tasks
tylerjw pushed a commit to PickNikRobotics/moveit that referenced this pull request May 12, 2020
tylerjw pushed a commit to PickNikRobotics/moveit that referenced this pull request May 12, 2020
tylerjw pushed a commit to PickNikRobotics/moveit that referenced this pull request May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants