8 int main (
int argc,
char **argv ) {
38 std::vector<double> beta;
51 case SLAMTechnique::EKF:
53 beta = std::vector<double> ( 18 ) ;
74 zt_ = std::make_shared<tuw::MeasurementMarker>();
97 tf_listener_ = std::make_shared<tf::TransformListener>();
104 case SLAMTechnique::EKF:
130 if (
slam_technique_->time_last_update().is_not_a_date_time() )
return;
147 catch (std::exception &ex) {
157 xt_.pose.pose.position.x =
yt_[0].x();
158 xt_.pose.pose.position.y =
yt_[0].y();
159 xt_.pose.pose.position.z = 0;
162 cv::Matx<double, 3, 3> C_X2 = cv::Mat_<double> (
C_Yt_, cv::Range ( 0, 3 ), cv::Range ( 0, 3 ) );
163 xt_.pose.covariance[6*0 + 0] = C_X2 ( 0, 0 );
164 xt_.pose.covariance[6*0 + 1] = C_X2 ( 0, 1 );
165 xt_.pose.covariance[6*0 + 5] = C_X2 ( 0, 2 );
166 xt_.pose.covariance[6*1 + 0] = C_X2 ( 1, 0 );
167 xt_.pose.covariance[6*1 + 1] = C_X2 ( 1, 1 );
168 xt_.pose.covariance[6*1 + 5] = C_X2 ( 1, 2 );
169 xt_.pose.covariance[6*5 + 0] = C_X2 ( 2, 0 );
170 xt_.pose.covariance[6*5 + 1] = C_X2 ( 2, 1 );
171 xt_.pose.covariance[6*5 + 5] = C_X2 ( 2, 2 );
179 mt_.markers.resize (
yt_.size() - 1 );
180 for (
size_t i = 0; i <
mt_.markers.size(); i++ ) {
181 mt_.markers[i].marker.ids.resize(1);
182 mt_.markers[i].marker.ids_confidence.resize(1);
183 mt_.markers[i].marker.ids[0] = i + 1;
184 mt_.markers[i].marker.ids_confidence[0] = 1.0;
186 mt_.markers[i].marker.pose.position.x =
yt_[i+1].x();
187 mt_.markers[i].marker.pose.position.y =
yt_[i+1].y();
188 mt_.markers[i].marker.pose.position.z = 0;
191 cv::Matx<double, 3, 3> C_Mi2 = cv::Mat_<double> (
C_Yt_, cv::Range ( 3* ( i+1 ), 3* ( i+1 ) + 3 ), cv::Range ( 3* ( i+1 ), 3* ( i+1 ) + 3 ) );
192 mt_.markers[i].covariance[6*0 + 0] = C_Mi2 ( 0, 0 );
193 mt_.markers[i].covariance[6*0 + 1] = C_Mi2 ( 0, 1 );
194 mt_.markers[i].covariance[6*0 + 5] = C_Mi2 ( 0, 2 );
195 mt_.markers[i].covariance[6*1 + 0] = C_Mi2 ( 1, 0 );
196 mt_.markers[i].covariance[6*1 + 1] = C_Mi2 ( 1, 1 );
197 mt_.markers[i].covariance[6*1 + 5] = C_Mi2 ( 1, 2 );
198 mt_.markers[i].covariance[6*5 + 0] = C_Mi2 ( 2, 0 );
199 mt_.markers[i].covariance[6*5 + 1] = C_Mi2 ( 2, 1 );
200 mt_.markers[i].covariance[6*5 + 5] = C_Mi2 ( 2, 2 );
211 ut_.v() = cmd.linear.x;
212 ut_.w() = cmd.angular.z;
220 assert (
zt_->getType() == tuw::Measurement::Type::MARKER );
229 (
xzplane_ ) ? yaw + M_PI/2 : yaw );
232 zt->pose2d() = Pose2D ( 0.225, 0, 0 );
235 if ( ( _marker.view_direction.x == 0 ) && ( _marker.view_direction.y == 0 ) && ( _marker.view_direction.z == 0 ) && ( _marker.view_direction.w == 1 ) ) {
236 zt->angle_min() = -_marker.fov_horizontal/2.;
237 zt->angle_max() = _marker.fov_horizontal/2.;
242 zt->range_min() = _marker.distance_min;
243 zt->range_max() = _marker.distance_max;
244 zt->range_max_id() = _marker.distance_max_id;
245 zt->stamp() = _marker.header.stamp.toBoost();
248 for (
size_t i = 0; i < _marker.markers.size(); i++ ) {
260 theta = angle_difference(M_PI, pitch);
267 length = sqrt( x*x + y*y );
268 angle = atan2 ( y, x );
270 if (length < zt->range_min() || length > zt->range_max() ||
271 angle < zt->angle_min() || angle > zt->angle_max())
275 zt_i.
ids = _marker.markers[i].ids;
280 zt_i.
pose = Pose2D ( x, y, theta );
281 zt->push_back( zt_i );
291 ROS_INFO (
"callbackConfigEKFSLAM!" );
std::string frame_id_map_
measurements are in x-z-plane (gazebo) instead of x-y-plane (stage)
std::vector< double > ids_confidence
ros::Subscriber sub_marker_
subscriber to the command
static void pointMsgToTF(const geometry_msgs::Point &msg_v, Point &bt_v)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
static double getYaw(const Quaternion &bt_q)
std::shared_ptr< tf::TransformListener > tf_listener_
broadcasts transformation messages
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void callbackConfigSLAM(tuw_marker_slam::SLAMConfig &config, uint32_t level)
parameter server stuff general use
ros::Subscriber sub_cmd_
node handler to the current node
ROSCPP_DECL const std::string & getName()
TFSIMD_FORCE_INLINE const tfScalar & getY() const
void callbackConfigEKFSLAM(tuw_marker_slam::EKFSLAMConfig &config, uint32_t level)
parameter server stuff for the EKF SLAM
int main(int argc, char **argv)
SLAMTechniquePtr slam_technique_
counter for the triggered cycles
TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
std::string resolve(const std::string &prefix, const std::string &frame_name)
tuw_marker_slam::SLAMConfig config_
technique used to estimate landmark map and the vehicles pose in it
ros::Publisher pub_xt_
subscriber to the marker detector
bool xzplane_
listener to receive transformation messages
ros::Publisher pub_mt_
publisher for the estimated vehicle pose and its covariance
static Quaternion createQuaternionFromYaw(double yaw)
static void quaternionMsgToTF(const geometry_msgs::Quaternion &msg, Quaternion &bt)
void getRPY(tfScalar &roll, tfScalar &pitch, tfScalar &yaw, unsigned int solution_number=1) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
std::string frame_id_base_
frame id of odom (for transformations)
cv::Mat_< double > C_Yt_
combined state yt = (xt, mt_1, ..., mt_n) with xt = (x, y, alpha), mt_i = (x_i, y_i, alpha_i)
const std::string & getNamespace() const
void publish()
triggers the SLAM cycle
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
marker_msgs::MarkerWithCovarianceArray mt_
estimated vehicle pose and its covariance to publish
TFSIMD_FORCE_INLINE const tfScalar & z() const
SLAMNode(ros::NodeHandle &n)
std::shared_ptr< MeasurementMarker > MeasurementMarkerPtr
Prototype.
Command ut_
combined covariance matrix of combined state
void callbackCmd(const geometry_msgs::Twist &)
frame id of base (for transformations)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
MeasurementPtr zt_
motion commands v, w at time t
geometry_msgs::PoseWithCovarianceStamped xt_
publisher for the estimated landmark poses and their covariances
bool getParam(const std::string &key, std::string &s) const
TFSIMD_FORCE_INLINE const tfScalar & getX() const
static Time fromBoost(const boost::posix_time::ptime &t)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
std::string frame_id_odom_
frame id of map (for transformations)
dynamic_reconfigure::Server< tuw_marker_slam::SLAMConfig >::CallbackType reconfigureFncSLAM_
parameter server stuff general use
ros::NodeHandle n_param_
node handler to the root node
ros::NodeHandle n_
publishes the estimated landmark map and the estimated vehicle pose in it
ROSCPP_DECL void spinOnce()
dynamic_reconfigure::Server< tuw_marker_slam::SLAMConfig > reconfigureServerSLAM_
callback function to catch incoming marker data
std::vector< Pose2D > yt_
constructor
dynamic_reconfigure::Server< tuw_marker_slam::EKFSLAMConfig >::CallbackType reconfigureFncEKFSLAM_
parameter server stuff for the EKF SLAM
void callbackMarker(const marker_msgs::MarkerDetection &)
callback function to catch motion commands
tf::TransformBroadcaster tf_broadcaster_
estimated landmark poses and their covariances to publish
std::shared_ptr< dynamic_reconfigure::Server< tuw_marker_slam::EKFSLAMConfig > > reconfigureServerEKFSLAM_
callback function on incoming parameter changes for general use