35 #include <boost/interprocess/sync/scoped_lock.hpp> 37 #include <mrpt_bridge/pose.h> 38 #include <mrpt_bridge/laser_scan.h> 39 #include <mrpt_bridge/marker_msgs.h> 40 #include <mrpt_bridge/time.h> 42 #include <mrpt/version.h> 46 int main(
int argc,
char** argv)
80 mrpt::poses::CPose3D& des,
const std::string& target_frame,
81 const std::string& source_frame,
const ros::Time& time,
89 "debug: waitForTransform(): target_frame='%s' " 91 target_frame.c_str(), source_frame.c_str());
94 target_frame, source_frame, time, polling_sleep_duration);
96 target_frame, source_frame, time, transform);
101 "Failed to get transform target_frame (%s) to source_frame (%s)",
102 target_frame.c_str(), source_frame.c_str());
105 mrpt_bridge::convert(transform, des);
110 const nav_msgs::Odometry& src, mrpt::obs::CObservationOdometry& des)
112 mrpt_bridge::convert(src.header.stamp, des.timestamp);
113 mrpt_bridge::convert(src.pose.pose, des.odometry);
114 std::string odom_frame_id =
116 des.sensorLabel = odom_frame_id;
117 des.hasEncodersInfo =
false;
118 des.hasVelocities =
false;
139 mrpt::poses::CPose3D sensor_pose_on_robot;
141 if (
getStaticTF(_msg.header.frame_id, sensor_pose_on_robot))
160 mrpt::poses::CPose3D sensor_pose_on_robot;
162 if (
getStaticTF(_msg.header.frame_id, sensor_pose_on_robot))
181 ROS_INFO(
"Problem to syn data for sensor frame!");
184 auto odometry = CObservationOdometry::Create();
186 pRawLog.addObservationMemoryReference(odometry);
188 CObservation2DRangeScan::Ptr range_scan;
189 CObservationBearingRange::Ptr bearing_range;
190 CObservationBeaconRanges::Ptr beacon_range;
195 if (fabs(mrpt::system::timeDifference(
201 range_scan = CObservation2DRangeScan::Create();
203 pRawLog.addObservationMemoryReference(range_scan);
209 if (fabs(mrpt::system::timeDifference(
215 bearing_range = CObservationBearingRange::Create();
217 pRawLog.addObservationMemoryReference(bearing_range);
222 if (fabs(mrpt::system::timeDifference(
228 beacon_range = CObservationBeaconRanges::Create();
230 pRawLog.addObservationMemoryReference(beacon_range);
233 static std::shared_ptr<mrpt::poses::CPose2D> lastOdomPose;
236 lastOdomPose = std::make_shared<mrpt::poses::CPose2D>();
237 *lastOdomPose = odometry->odometry;
240 mrpt::poses::CPose2D incOdoPose = odometry->odometry - *lastOdomPose;
242 CActionRobotMovement2D odom_move;
243 odom_move.timestamp = odometry->timestamp;
245 auto action = CActionCollection::Create();
246 action->insert(odom_move);
249 auto sf = CSensoryFrame::Create();
252 CObservation::Ptr obs_range_scan = CObservation::Ptr(range_scan);
253 sf->insert(obs_range_scan);
258 CObservation::Ptr obs_bearing_range = CObservation::Ptr(bearing_range);
259 sf->insert(obs_bearing_range);
263 CObservation::Ptr obs_bearing_range = CObservation::Ptr(beacon_range);
264 sf->insert(obs_bearing_range);
266 pRawLogASF.addObservationsMemoryReference(sf);
268 *lastOdomPose = odometry->odometry;
274 std::string source_frame, mrpt::poses::CPose3D& des)
276 std::string target_frame_id =
278 std::string source_frame_id = source_frame;
279 std::string key = target_frame_id +
"->" + source_frame_id;
280 mrpt::poses::CPose3D pose;
289 "debug: updateLaserPose(): target_frame_id='%s' " 290 "source_frame_id='%s'",
291 target_frame_id.c_str(), source_frame_id.c_str());
294 target_frame_id, source_frame_id,
ros::Time(0), transform);
297 pose.x() = translation.
x();
298 pose.y() = translation.
y();
299 pose.z() = translation.
z();
301 mrpt::math::CMatrixDouble33 Rdes;
302 for (
int c = 0; c < 3; c++)
303 for (
int r = 0; r < 3; r++) Rdes(r, c) = Rsrc.
getRow(r)[c];
304 pose.setRotationMatrix(Rdes);
307 "Static tf '%s' with '%s'", key.c_str(),
308 pose.asString().c_str());
unsigned int sync_attempts_sensor_frame_
double bearing_range_std_pitch
mrpt::obs::CObservationBearingRange::Ptr last_bearing_range_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool getStaticTF(std::string source_frame, mrpt::poses::CPose3D &des)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void callbackLaser(const sensor_msgs::LaserScan &)
double sensor_frame_sync_threshold
int main(int argc, char **argv)
bool waitForTransform(mrpt::poses::CPose3D &des, const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration &timeout, const ros::Duration &polling_sleep_duration=ros::Duration(0.01))
double bearing_range_std_range
ros::Subscriber subOdometry_
ROSCPP_DECL void spin(Spinner &spinner)
TFSIMD_FORCE_INLINE const Vector3 & getRow(int i) const
std::string resolve(const std::string &prefix, const std::string &frame_name)
CActionRobotMovement2D::TMotionModelOptions motionModelOptions
TFSIMD_FORCE_INLINE const tfScalar & x() const
std::string odom_frame_id
TFSIMD_FORCE_INLINE const tfScalar & z() const
mrpt::obs::CObservation2DRangeScan::Ptr last_range_scan_
std::string base_frame_id
double bearing_range_std_yaw
TFSIMD_FORCE_INLINE const tfScalar & y() const
void convert(const nav_msgs::Odometry &src, mrpt::obs::CObservationOdometry &des)
tf::TransformListener listenerTF_
std::map< std::string, mrpt::poses::CPose3D > static_tf_
void addObservation(const ros::Time &time)
void updateRawLogName(const mrpt::system::TTimeStamp &t)
void callbackOdometry(const nav_msgs::Odometry &)
mrpt::obs::CObservationBeaconRanges::Ptr last_beacon_range_
mrpt::obs::CObservationOdometry::Ptr last_odometry_
ros::Subscriber subLaser_
RawlogRecordNode(ros::NodeHandle &n)
void callbackMarker(const marker_msgs::MarkerDetection &)
bool record_bearing_range
ros::Subscriber subMarker_