ContactSensor.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 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 /* Desc: Contact sensor 00018 * Author: Nate Koenig 00019 * Date: 09 Sept. 2008 00020 */ 00021 00022 #ifndef CONTACTSENSOR_HH 00023 #define CONTACTSENSOR_HH 00024 00025 #include <vector> 00026 00027 #include <stdint.h> 00028 00029 #include "math/Angle.hh" 00030 #include "sensors/Sensor.hh" 00031 #include "physics/Contact.hh" 00032 00033 namespace gazebo 00034 { 00035 namespace sensors 00036 { 00037 class Contact; 00038 00041 00045 class ContactSensor: public Sensor 00046 { 00050 public: ContactSensor(); 00051 00053 public: virtual ~ContactSensor(); 00054 00057 public: virtual void Load( sdf::ElementPtr &_sdf ); 00058 public: virtual void Load( ); 00059 00061 public: virtual void Init(); 00062 00064 protected: virtual void UpdateImpl(bool force); 00065 00067 protected: virtual void Fini(); 00068 00070 public: unsigned int GetCollisionCount() const; 00071 00073 public: std::string GetCollisionName(unsigned int _index) const; 00074 00076 public: unsigned int GetCollisionContactCount( 00077 const std::string &_collisionName) const; 00078 00080 public: physics::Contact GetCollisionContact( 00081 const std::string &_collisionName, unsigned int _index) const; 00082 00083 public: gazebo::physics::ModelPtr GetParentModel() {return this->model;}; 00084 00085 public: std::map<std::string, physics::Contact> GetContacts( 00086 const std::string &_collisionName); 00087 00088 private: void OnContact(const std::string &_collisionName, 00089 const physics::Contact &_contact); 00090 00091 private: std::vector<physics::CollisionPtr> collisions; 00092 00093 private: gazebo::physics::ModelPtr model; 00094 private: typedef 00095 std::map<std::string, std::map<std::string, physics::Contact> > Contact_M; 00096 private: Contact_M contacts; 00097 00098 private: transport::NodePtr node; 00099 private: transport::PublisherPtr contactsPub; 00100 00101 private: boost::mutex *mutex; 00102 public: boost::mutex* GetUpdateMutex() const {return this->mutex;} 00103 }; 00105 } 00106 } 00107 00108 #endif

1.7.5.1