00001 /* 00002 * Copyright 2016 Pavel Vechersky, ASL, ETH Zurich, Switzerland 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef ROTORS_HIL_INTERFACE_NODE_H_ 00018 #define ROTORS_HIL_INTERFACE_NODE_H_ 00019 00020 #include <memory> 00021 00022 #include <rotors_hil_interface/hil_interface.h> 00023 00024 namespace rotors_hil { 00025 // Default values 00026 static constexpr bool kDefaultSensorLevelHil = true; 00027 static constexpr double kDefaultHilFrequency = 100.0; 00028 static constexpr double kDefaultBodyToSensorsRoll = M_PI; 00029 static constexpr double kDefaultBodyToSensorsPitch = 0.0; 00030 static constexpr double kDefaultBodyToSensorsYaw = 0.0; 00031 static const std::string kDefaultMavlinkPubTopic = "mavlink/to"; 00032 static const std::string kDefaultHilControlsSubTopic = "mavros/hil_controls/hil_controls"; 00033 00034 class HilInterfaceNode { 00035 public: 00036 HilInterfaceNode(); 00037 virtual ~HilInterfaceNode(); 00038 00040 void MainTask(); 00041 00044 void HilControlsCallback(const mavros_msgs::HilControlsConstPtr& hil_controls_msg); 00045 00046 private: 00048 ros::NodeHandle nh_; 00049 00051 ros::Publisher actuators_pub_; 00052 00054 ros::Publisher mavlink_pub_; 00055 00057 ros::Subscriber hil_controls_sub_; 00058 00060 ros::Rate rate_; 00061 00063 std::unique_ptr<HilInterface> hil_interface_; 00064 }; 00065 } 00066 00067 #endif // ROTORS_HIL_INTERFACE_NODE_H_