|
32 | 32 | #include <base/samples/DepthMap.hpp> |
33 | 33 | #include <base/TransformWithCovariance.hpp> |
34 | 34 | #include <base/samples/Sonar.hpp> |
| 35 | +#include <base/samples/PoseWithCovariance.hpp> |
35 | 36 | #include <base/Temperature.hpp> |
36 | 37 | #include <base/Time.hpp> |
37 | 38 | #include <base/TimeMark.hpp> |
@@ -1525,6 +1526,85 @@ BOOST_AUTO_TEST_CASE( transform_with_covariance ) |
1525 | 1526 | BOOST_CHECK( t1.getCovariance().isApprox( t1r.getCovariance(), sigma ) ); |
1526 | 1527 | } |
1527 | 1528 |
|
| 1529 | +BOOST_AUTO_TEST_CASE( pose_with_covariance ) |
| 1530 | +{ |
| 1531 | + base::samples::RigidBodyState rbs; |
| 1532 | + rbs.time = base::Time::fromSeconds(1000); |
| 1533 | + rbs.sourceFrame = "laser"; |
| 1534 | + rbs.targetFrame = "body"; |
| 1535 | + rbs.position = base::Vector3d(1,2,3); |
| 1536 | + rbs.cov_position = 0.1 * base::Matrix3d::Identity(); |
| 1537 | + rbs.orientation = Eigen::AngleAxisd(0.5*M_PI,Eigen::Vector3d::UnitZ()) * |
| 1538 | + Eigen::AngleAxisd(-0.2*M_PI,Eigen::Vector3d::UnitY()) * |
| 1539 | + Eigen::AngleAxisd(0.1*M_PI,Eigen::Vector3d::UnitX()); |
| 1540 | + rbs.cov_orientation = 0.02 * base::Matrix3d::Identity(); |
| 1541 | + |
| 1542 | + base::samples::PoseWithCovariance t(rbs); |
| 1543 | + BOOST_CHECK(rbs.time == t.time); |
| 1544 | + BOOST_CHECK(rbs.sourceFrame == t.object_frame_id); |
| 1545 | + BOOST_CHECK(rbs.targetFrame == t.frame_id); |
| 1546 | + BOOST_CHECK(rbs.position.isApprox(t.transform.translation, 1e-12)); |
| 1547 | + BOOST_CHECK(rbs.cov_position.isApprox(t.transform.getTranslationCov(), 1e-12)); |
| 1548 | + BOOST_CHECK(rbs.orientation.isApprox(t.transform.orientation, 1e-12)); |
| 1549 | + BOOST_CHECK(rbs.cov_orientation.isApprox(t.transform.getOrientationCov(), 1e-12)); |
| 1550 | + |
| 1551 | + base::samples::RigidBodyState rbs2 = t.toRigidBodyState(); |
| 1552 | + BOOST_CHECK(rbs.time == rbs2.time); |
| 1553 | + BOOST_CHECK(rbs.sourceFrame == rbs2.sourceFrame); |
| 1554 | + BOOST_CHECK(rbs.targetFrame == rbs2.targetFrame); |
| 1555 | + BOOST_CHECK(rbs.position.isApprox(rbs2.position, 1e-12)); |
| 1556 | + BOOST_CHECK(rbs.cov_position.isApprox(rbs2.cov_position, 1e-12)); |
| 1557 | + BOOST_CHECK(rbs.orientation.isApprox(rbs2.orientation, 1e-12)); |
| 1558 | + BOOST_CHECK(rbs.cov_orientation.isApprox(rbs2.cov_orientation, 1e-12)); |
| 1559 | + |
| 1560 | + // test operator* |
| 1561 | + base::Matrix6d lt1; |
| 1562 | + lt1 << |
| 1563 | + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1564 | + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1565 | + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1566 | + 0.0, 0.0, 0.0, -3.0, 0.0, 0.0, |
| 1567 | + 0.0, 0.0, 0.0, 0.0, -2.0, 0.0, |
| 1568 | + 0.0, 0.0, 0.0, 0.0, 0.0, -1.0; |
| 1569 | + base::samples::PoseWithCovariance body_in_world(base::TransformWithCovariance( |
| 1570 | + Eigen::Affine3d(Eigen::Translation3d(Eigen::Vector3d(1,0,0)) * Eigen::AngleAxisd( M_PI/2.0, Eigen::Vector3d::UnitX()) ), |
| 1571 | + lt1 )); |
| 1572 | + body_in_world.time = base::Time(); |
| 1573 | + |
| 1574 | + base::Matrix6d lt2; |
| 1575 | + lt2 << |
| 1576 | + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1577 | + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1578 | + 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, |
| 1579 | + 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, |
| 1580 | + 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, |
| 1581 | + 0.0, 0.0, 0.0, 0.0, 0.0, 3.0; |
| 1582 | + base::samples::PoseWithCovariance sensor_in_body(base::TransformWithCovariance( |
| 1583 | + Eigen::Affine3d(Eigen::Translation3d(Eigen::Vector3d(0,1,2)) * Eigen::AngleAxisd( M_PI/2.0, Eigen::Vector3d::UnitY()) ), |
| 1584 | + lt2 )); |
| 1585 | + sensor_in_body.time = base::Time::now(); |
| 1586 | + |
| 1587 | + body_in_world.frame_id = "world"; |
| 1588 | + body_in_world.object_frame_id = "body"; |
| 1589 | + sensor_in_body.object_frame_id = "sensor"; |
| 1590 | + sensor_in_body.frame_id = "body"; |
| 1591 | + base::samples::PoseWithCovariance sensor_in_world = body_in_world * sensor_in_body; |
| 1592 | + |
| 1593 | + // check composition |
| 1594 | + BOOST_CHECK(sensor_in_world.object_frame_id == sensor_in_body.object_frame_id); |
| 1595 | + BOOST_CHECK(sensor_in_world.frame_id == body_in_world.frame_id); |
| 1596 | + BOOST_CHECK(sensor_in_world.time == sensor_in_body.time); |
| 1597 | + |
| 1598 | + base::samples::PoseWithCovariance body_in_world_r(sensor_in_world.transform.compositionInv(sensor_in_body.transform)); |
| 1599 | + base::samples::PoseWithCovariance sensor_in_body_r(sensor_in_world.transform.preCompositionInv(body_in_world.transform)); |
| 1600 | + |
| 1601 | + BOOST_CHECK( body_in_world.getTransform().matrix().isApprox( body_in_world_r.getTransform().matrix(), 1e-12 ) ); |
| 1602 | + BOOST_CHECK( body_in_world.getCovariance().isApprox( body_in_world_r.getCovariance(), 1e-12 ) ); |
| 1603 | + |
| 1604 | + BOOST_CHECK( sensor_in_body.getTransform().matrix().isApprox( sensor_in_body_r.getTransform().matrix(), 1e-12 ) ); |
| 1605 | + BOOST_CHECK( sensor_in_body.getCovariance().isApprox( sensor_in_body_r.getCovariance(), 1e-12 ) ); |
| 1606 | +} |
| 1607 | + |
1528 | 1608 | #ifdef SISL_FOUND |
1529 | 1609 | #include <base/geometry/spline.h> |
1530 | 1610 | BOOST_AUTO_TEST_CASE( spline_to_points ) |
|
0 commit comments