NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
localization_nodelet.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef LOCALIZATION_NODE_LOCALIZATION_NODELET_H_
20 #define LOCALIZATION_NODE_LOCALIZATION_NODELET_H_
21 
23 
26 
27 #include <ff_msgs/ResetMap.h>
28 #include <ff_msgs/SetBool.h>
29 #include <ff_util/ff_nodelet.h>
30 #include <nodelet/nodelet.h>
31 #include <image_transport/image_transport.h>
32 
33 #include <string>
34 #include <thread>
35 
36 namespace localization_node {
37 
39  public:
41  virtual ~LocalizationNodelet();
42 
43  protected:
44  virtual void Initialize(ros::NodeHandle* nh);
45 
46  private:
47  // Wrapper function that calls ReadParams but does not take a param,
48  // required for configuring with a config timer.
49  void ReadParamsWrapper();
50  bool ReadParams(bool fatal_failure = true);
51  bool ResetMap(const std::string& map_file);
52  void Run(void);
53  void Localize(void);
54  void ImageCallback(const sensor_msgs::ImageConstPtr& msg);
55  bool EnableService(ff_msgs::SetBool::Request & req, ff_msgs::SetBool::Response & res);
56  bool ResetMapService(ff_msgs::ResetMap::Request & req, ff_msgs::ResetMap::Response & res);
57 
58  std::shared_ptr<Localizer> inst_;
59  std::shared_ptr<sparse_mapping::SparseMap> map_;
60  std::shared_ptr<std::thread> thread_;
62  std::string last_valid_map_file_;
63  ros::Timer config_timer_;
64 
65  std::shared_ptr<image_transport::ImageTransport> it_;
66  image_transport::Subscriber image_sub_;
67  ros::ServiceServer enable_srv_, reset_map_srv_;
68  ros::ServiceClient reset_map_loc_client_;
69  ros::Publisher registration_publisher_, landmark_publisher_,
70  detected_features_publisher_, used_features_publisher_, all_features_publisher_;
71  bool enabled_;
72  int count_;
73 
74  bool matched_features_on_, all_features_on_;
75  cv_bridge::CvImageConstPtr image_ptr_;
76 
77  volatile bool processing_image_;
78  pthread_mutex_t mutex_features_;
79  pthread_cond_t cond_features_;
80 };
81 
82 }; // namespace localization_node
83 
84 #endif // LOCALIZATION_NODE_LOCALIZATION_NODELET_H_
85 
localization_node
Definition: localization.h:32
ff_nodelet.h
localization.h
ff_util::FreeFlyerNodelet
Definition: ff_nodelet.h:57
config_reader::ConfigReader
Definition: config_reader.h:48
localization_node::LocalizationNodelet::~LocalizationNodelet
virtual ~LocalizationNodelet()
Definition: localization_nodelet.cc:45
config_reader.h
localization_node::LocalizationNodelet::Initialize
virtual void Initialize(ros::NodeHandle *nh)
Definition: localization_nodelet.cc:93
localization_node::LocalizationNodelet::LocalizationNodelet
LocalizationNodelet()
Definition: localization_nodelet.cc:39
sparse_map.h
localization_node::LocalizationNodelet
Definition: localization_nodelet.h:38