50 joint_state_cache_.setMaxSize(max_size);
55 joint_names_ = joint_names;
56 deflater_.setDeflationJointNames(joint_names);
62 deflater_.deflate(joint_state, deflated);
64 joint_state_cache_.add(deflated);
71 ROS_DEBUG(
"Checking if snapshot is early:");
72 if (joint_state_cache_.size() == 0)
74 ROS_DEBUG(
" cache is empty, so snapshot is definitely early");
77 if (snapshot.scan_start.size() == 0)
78 ROS_FATAL(
"Received malformed DenseLaserSnapshot. (scan_start.size() == 0)");
79 ros::Time snapshot_end = snapshot.scan_start.back() +
ros::Duration(snapshot.time_increment*(snapshot.num_scans-1));
81 ros::Time cache_front = joint_state_cache_.front().header.stamp;
82 ros::Time cache_back = joint_state_cache_.back().header.stamp;
83 ROS_DEBUG(
" Newest elem in cache (back): %u.%u", cache_back.
sec, cache_back.
nsec);
84 ROS_DEBUG(
" Oldest elem in cache (front): %u.%u", cache_front.
sec, cache_front.
nsec);
94 ROS_DEBUG(
"Checking if snapshot is late:");
95 if (joint_state_cache_.size() == 0)
97 ROS_DEBUG(
" cache is empty, so snapshot isn't late yet");
101 if (snapshot.scan_start.size() == 0)
102 ROS_FATAL(
"Received malformed DenseLaserSnapshot. (scan_start.size() == 0)");
103 ros::Time snapshot_start = snapshot.scan_start.front();
104 ros::Time cache_front = joint_state_cache_.front().header.stamp;
105 ros::Time cache_back = joint_state_cache_.back().header.stamp;
109 ROS_DEBUG(
" Newest elem in cache (back): %u.%u", cache_back.
sec, cache_back.
nsec);
110 ROS_DEBUG(
" Oldest elem in cache (front): %u.%u", cache_front.sec, cache_front.nsec);
111 ROS_DEBUG(
" Start of snapshot: %u.%u", snapshot_start.
sec, snapshot_start.
nsec);
118 const calibration_msgs::CalibrationPattern& features,
119 calibration_msgs::JointStateCalibrationPattern& result,
123 const unsigned int num_joints = joint_names_.size();
125 const unsigned int P = features.image_points.size();
127 result.object_points = features.object_points;
128 result.joint_points.clear();
129 result.joint_points.resize(P);
132 success = imager_.update(snapshot, joint_state_cache_, max_interp);
174 for (
unsigned int j=0; j<num_joints; j++)
177 vector<float> positions;
178 vector<float> velocities;
179 interp_.interp(features.image_points, imager_.getJointImage(j),
180 positions, velocities);
182 for (
unsigned int i=0; i<P; i++)
184 result.joint_points[i].name.push_back(joint_names_[j]);
185 result.joint_points[i].position.push_back(positions[i]);
186 result.joint_points[i].velocity.push_back(velocities[i]);
187 result.joint_points[i].effort.push_back(1234);
191 vector<float> laser_angles;
192 vector<float> laser_ranges;
194 success =
interpSnapshot(features.image_points, snapshot, laser_angles, laser_ranges);
201 for (
unsigned int i=0; i<P; i++)
203 result.joint_points[i].name.push_back(
"laser_angle_joint");
204 result.joint_points[i].position.push_back(laser_angles[i]);
205 result.joint_points[i].velocity.push_back(0);
206 result.joint_points[i].effort.push_back(1234);
208 result.joint_points[i].name.push_back(
"laser_range_joint");
209 result.joint_points[i].position.push_back(laser_ranges[i]);
210 result.joint_points[i].velocity.push_back(0);
211 result.joint_points[i].effort.push_back(1234);
214 result.header.stamp = snapshot.header.stamp;
bool addJointState(const sensor_msgs::JointStateConstPtr &joint_state)
bool interpSnapshot(const std::vector< geometry_msgs::Point > &points, const calibration_msgs::DenseLaserSnapshot &snapshot, std::vector< float > &pointing_angles, std::vector< float > &ranges)
void setCacheSize(unsigned int max_size)
bool processLaserData(const calibration_msgs::DenseLaserSnapshot &snapshot, const calibration_msgs::CalibrationPattern &features, calibration_msgs::JointStateCalibrationPattern &result, const ros::Duration &max_interp=ros::Duration(.25))
bool isSnapshotLate(const calibration_msgs::DenseLaserSnapshot &snapshot) const
bool isSnapshotEarly(const calibration_msgs::DenseLaserSnapshot &snapshot) const
void setJointNames(const std::vector< std::string > &joint_names)