NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
validator.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 CHOREOGRAPHER_VALIDATOR_H_
20 #define CHOREOGRAPHER_VALIDATOR_H_
21 
22 // ROS libraries
23 #include <ros/ros.h>
24 
25 // ROS messages
26 #include <visualization_msgs/MarkerArray.h>
27 
28 // FSW utils
29 #include <ff_util/ff_flight.h>
31 #include <ff_util/config_server.h>
32 
33 // FSW messages
34 #include <ff_msgs/Zone.h>
35 #include <ff_msgs/SetZones.h>
36 #include <ff_msgs/GetZones.h>
37 #include <ff_msgs/GetOccupancyMap.h>
38 #include <ff_msgs/GetFloat.h>
39 
40 // Voxel map
41 #include <jps3d/planner/jps_3d_util.h>
42 
43 // STL includes
44 #include <string>
45 #include <vector>
46 
47 #define EPS 0.001
48 
49 namespace choreographer {
50 
51 class Validator {
52  public:
53  // Possible responses
54  enum Response : uint8_t {
67  };
68 
69  // Load the keep in the keeo out zones and return if successful
70  bool Init(ros::NodeHandle *nh, ff_util::ConfigServer & cfg);
71 
72  // If the check fails, then the info block is populated
74  ff_msgs::FlightMode const& flight_mode, bool face_forward);
75 
76  protected:
77  // Markers for keep in / keep out zones
78  void PublishMarkers();
79 
80  // Process zones when building the occupancy map
81  void ProcessZone(std::vector<signed char>& map, int type, char cell_value, bool surface);
82 
83  // Build the occupancy map
84  bool GetZonesMap();
85 
86  // Callback to get the keep in/out zones
87  bool GetZonesCallback(ff_msgs::GetZones::Request& req,
88  ff_msgs::GetZones::Response& res);
89 
90  // Callback to get the keep in/out zones map
91  bool GetZonesMapCallback(ff_msgs::GetOccupancyMap::Request& req,
92  ff_msgs::GetOccupancyMap::Response& res);
93 
94  // Callback to set the keep in/out zones
95  bool SetZonesCallback(ff_msgs::SetZones::Request& req,
96  ff_msgs::SetZones::Response& res);
97 
98  private:
99  std::string zone_file_; // Zone file path
100  bool overwrite_; // New zones overwrite
101  ff_msgs::SetZones::Request zones_; // Zones
102  ros::Publisher pub_zones_; // Zone publisher
103  ros::ServiceServer get_zones_srv_; // Get zones service
104  ros::ServiceServer get_zones_map_srv_; // Get zones map
105  ros::ServiceServer set_zones_srv_; // Set zones service
106  ros::ServiceClient get_resolution_; // Get the zones map resolution
107  ros::ServiceClient get_map_inflation_; // Get the zones map inflation
108 
109  double map_res_ = 0.08;
110  std::shared_ptr<JPS::VoxelMapUtil> jps_map_util_;
111 
112  // Voxel map values
113  char val_occ_ = 100; // Assume occupied cell has value 100
114  char val_free_ = 0; // Assume free cell has value 0
115  char val_unknown_ = -1; // Assume unknown cell has value -1
116 };
117 
118 } // namespace choreographer
119 
120 #endif // CHOREOGRAPHER_VALIDATOR_H_
choreographer::Validator::VIOLATES_HARD_LIMIT_ACCEL
@ VIOLATES_HARD_LIMIT_ACCEL
Definition: validator.h:64
choreographer::Validator::Response
Response
Definition: validator.h:54
choreographer::Validator
Definition: validator.h:51
choreographer::Validator::GetZonesMap
bool GetZonesMap()
Definition: validator.cc:81
choreographer::Validator::SUCCESS
@ SUCCESS
Definition: validator.h:55
choreographer::Validator::VIOLATES_STATIONARY_ENDPOINT
@ VIOLATES_STATIONARY_ENDPOINT
Definition: validator.h:60
choreographer::Validator::VIOLATES_FIRST_IN_PAST
@ VIOLATES_FIRST_IN_PAST
Definition: validator.h:61
ff_flight.h
choreographer::Validator::VIOLATES_HARD_LIMIT_ALPHA
@ VIOLATES_HARD_LIMIT_ALPHA
Definition: validator.h:66
ff_util::ConfigServer
Definition: config_server.h:45
ff_serialization.h
ff_util::Segment
std::vector< Setpoint > Segment
Definition: ff_flight.h:47
config_server.h
choreographer::Validator::ProcessZone
void ProcessZone(std::vector< signed char > &map, int type, char cell_value, bool surface)
Definition: validator.cc:27
choreographer::Validator::Init
bool Init(ros::NodeHandle *nh, ff_util::ConfigServer &cfg)
Definition: validator.cc:216
choreographer::Validator::PublishMarkers
void PublishMarkers()
Definition: validator.cc:256
choreographer::Validator::VIOLATES_MINIMUM_FREQUENCY
@ VIOLATES_MINIMUM_FREQUENCY
Definition: validator.h:59
choreographer::Validator::CheckSegment
Response CheckSegment(ff_util::Segment const &msg, ff_msgs::FlightMode const &flight_mode, bool face_forward)
Definition: validator.cc:161
choreographer::Validator::VIOLATES_MINIMUM_SETPOINTS
@ VIOLATES_MINIMUM_SETPOINTS
Definition: validator.h:62
choreographer::Validator::VIOLATES_HARD_LIMIT_VEL
@ VIOLATES_HARD_LIMIT_VEL
Definition: validator.h:63
choreographer::Validator::SetZonesCallback
bool SetZonesCallback(ff_msgs::SetZones::Request &req, ff_msgs::SetZones::Response &res)
Definition: validator.cc:340
choreographer::Validator::GetZonesMapCallback
bool GetZonesMapCallback(ff_msgs::GetOccupancyMap::Request &req, ff_msgs::GetOccupancyMap::Response &res)
Definition: validator.cc:318
choreographer::Validator::VIOLATES_KEEP_IN
@ VIOLATES_KEEP_IN
Definition: validator.h:58
choreographer
Definition: validator.h:49
choreographer::Validator::VIOLATES_HARD_LIMIT_OMEGA
@ VIOLATES_HARD_LIMIT_OMEGA
Definition: validator.h:65
choreographer::Validator::GetZonesCallback
bool GetZonesCallback(ff_msgs::GetZones::Request &req, ff_msgs::GetZones::Response &res)
Definition: validator.cc:310
choreographer::Validator::VIOLATES_KEEP_OUT
@ VIOLATES_KEEP_OUT
Definition: validator.h:57
choreographer::Validator::VIOLATES_RESAMPLING
@ VIOLATES_RESAMPLING
Definition: validator.h:56