ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

bullet_migration: electric and fuerte compatibility

asked 2012-08-07 10:19:56 -0500

bwasserm gravatar image

updated 2012-08-07 22:48:30 -0500

AHornung gravatar image

Hello, I'm trying to upgrade a project from Electric to Fuerte while still maintaining Electric compatibility (some systems will be on Electric for a while). I ran into an issue with tf and bullet. In the following code section, I need R defined as a btMatrix3x3 in Electric, but a tf::Matrix3x3 in Fuerte. Is there any way to have one set of code that will satisfy both? I would like to stay with the recommended Fuerte form, but I need it to work in both versions.

//world_to_camera is a tf::StampedTransform
//Electric version
btMatrix3x3 R;
R.setRotation(world_to_camera.inverse().getRotation());

Edit: In Electric, the error comes at tf::Matrix3x3 (Matrix3x3 is not a member of tf). In Fuerte, the error is at R.setRotation (no matching function call btMatrix3x3::setRotation(tf::Quaternion, can't convert tf::Quaternion to btQuaternion.) I tried putting .toBt() after .getRotation() in the migration guide, but I got the error Class tf::Quaternion has no member toBt.

I tried to follow the bullet_migration guide. The sed script doesn't work because it breaks in Electric. I'm sorry if this answer is obvious somewhere. Thanks for the help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2012-08-07 22:47:21 -0500

AHornung gravatar image

updated 2012-08-08 03:55:40 -0500

You can switch between fuerte and electric with the following code:

#if ROS_VERSION_MINIMUM(1,8,0)
  tf::Matrix3x3 R;      
#else
  btMatrix3x3 R;
#endif

R.setRotation(world_to_camera.inverse().getRotation());
edit flag offensive delete link more

Comments

Alternatively, if you have many occurrences of btMatrix3x3, you can put a typedef in a header file that defines tf::Matrix3x3 for older ros versions.

Lorenz gravatar image Lorenz  ( 2012-08-07 23:23:07 -0500 )edit

Thanks, that worked. Except you got the types backwards, but I got the idea of what you meant.

bwasserm gravatar image bwasserm  ( 2012-08-08 03:52:28 -0500 )edit

Ah right - I'll edit that. You should also consider what Lorenz wrote, in case you have multiple occurrences.

AHornung gravatar image AHornung  ( 2012-08-08 03:54:40 -0500 )edit

Cool. And I would, but for some reason its only the one definition that causes problems. It is probably the right way to go though.

bwasserm gravatar image bwasserm  ( 2012-08-08 03:58:17 -0500 )edit

Question Tools

Stats

Asked: 2012-08-07 10:19:56 -0500

Seen: 988 times

Last updated: Aug 08 '12