MCPcopy Create free account
hub / github.com/KumarRobotics/sloam / OdomCb_

Method OdomCb_

sloam/src/core/inputNode.cpp:101–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void InputManager::OdomCb_(const nav_msgs::OdometryConstPtr &odom_msg)
102{
103 odomCounter_++;
104 if (odomCounter_ % odomFreqFilter_ != 0)
105 return;
106 odomCounter_ = 0;
107
108 auto pose = odom_msg->pose.pose;
109 ros::Time odomStamp = odom_msg->header.stamp;
110 Quat rot(pose.orientation.w, pose.orientation.x,
111 pose.orientation.y, pose.orientation.z);
112 Vector3 pos(pose.position.x, pose.position.y, pose.position.z);
113
114 SE3 odom = SE3();
115 odom.setQuaternion(rot);
116 odom.translation() = pos;
117
118 // odom is in cam frame, we need it in robot frame
119 geometry_msgs::TransformStamped transform_cam_body;
120 try
121 {
122 auto transform_cam_body = tf_buffer_.lookupTransform(
123 odom_msg->child_frame_id, robot_frame_id_, ros::Time(0));
124 SE3 cam_body_tf(tf2::transformToEigen(transform_cam_body).matrix().cast<double>());
125 odom = odom * cam_body_tf;
126 }
127 catch (tf2::TransformException &ex)
128 {
129 ROS_INFO_THROTTLE(10, "Camera to body transform is not found, now setting it as identity... If you're in simulator, ignore this.");
130 }
131
132 if (firstOdom_ && pose.position.z < minSLOAMAltitude_)
133 {
134 ROS_INFO_THROTTLE(5, "Quad is too low, will not call sloam");
135 return;
136 }
137
138 odomQueue_.emplace_back(odom, odomStamp);
139 if (odomQueue_.size() > 10 * maxQueueSize_)
140 odomQueue_.pop_front();
141}
142
143bool InputManager::Run()
144{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected