NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
access_control.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 ACCESS_CONTROL_ACCESS_CONTROL_H_
20 #define ACCESS_CONTROL_ACCESS_CONTROL_H_
21 
22 #include <pluginlib/class_list_macros.h>
23 #include <ros/ros.h>
24 
26 #include <ff_msgs/AccessControlStateStamped.h>
27 #include <ff_msgs/AckCompletedStatus.h>
28 #include <ff_msgs/AckStamped.h>
29 #include <ff_msgs/AckStatus.h>
30 #include <ff_msgs/CommandConstants.h>
31 #include <ff_msgs/CommandStamped.h>
32 #include <ff_common/ff_names.h>
33 #include <ff_util/ff_nodelet.h>
34 
35 #include <cstdint>
36 #include <iostream>
37 #include <random>
38 #include <string>
39 
40 namespace access_control {
41 
43  public:
44  AccessControl();
46 
47  protected:
48  virtual void Initialize(ros::NodeHandle *nh);
49 
50  private:
51  std::string GenerateCookie();
52 
53  void HandleCommand(ff_msgs::CommandStampedConstPtr const& cmd);
54 
55  void HandleGrabControl(ff_msgs::CommandStampedConstPtr const& cmd);
56 
57  void HandleRequestControl(ff_msgs::CommandStampedConstPtr const& cmd);
58 
59  void PublishAck(std::string const& cmd_id,
60  std::string const& message = "",
61  uint8_t completed_status = ff_msgs::AckCompletedStatus::OK,
62  uint8_t status = ff_msgs::AckStatus::COMPLETED);
63 
64  void PublishCommand(ff_msgs::CommandStampedConstPtr const& cmd);
65 
66  void PublishState();
67 
68  ff_msgs::AccessControlStateStamped state_;
69  ff_msgs::AckStamped ack_;
70 
71  int pub_queue_size_;
72  int sub_queue_size_;
73 
74  ros::Publisher cmd_ack_pub_, state_pub_, cmd_pub_, failed_cmd_pub_;
75  ros::Subscriber cmd_sub_;
76 
77  std::string requestor_;
78 };
79 
80 } // namespace access_control
81 
82 #endif // ACCESS_CONTROL_ACCESS_CONTROL_H_
access_control
Definition: access_control.h:40
ff_nodelet.h
ff_util::FreeFlyerNodelet
Definition: ff_nodelet.h:57
ff_names.h
access_control::AccessControl::Initialize
virtual void Initialize(ros::NodeHandle *nh)
Definition: access_control.cc:39
access_control::AccessControl::AccessControl
AccessControl()
Definition: access_control.cc:30
access_control::AccessControl
Definition: access_control.h:42
config_reader.h
access_control::AccessControl::~AccessControl
~AccessControl()
Definition: access_control.cc:36