ContactSensor.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef _GAZEBO_SENSORS_CONTACTSENSOR_HH_
18#define _GAZEBO_SENSORS_CONTACTSENSOR_HH_
19
20#include <map>
21#include <string>
22#include <memory>
23
24#include "gazebo/msgs/msgs.hh"
25
28#include "gazebo/util/system.hh"
29
30namespace gazebo
31{
34 namespace sensors
35 {
36 // Forward declare private data class
37 class ContactSensorPrivate;
38
41
45 class GZ_SENSORS_VISIBLE ContactSensor: public Sensor
46 {
48 public: ContactSensor();
49
51 public: virtual ~ContactSensor();
52
56 public: virtual void Load(const std::string &_worldName,
57 sdf::ElementPtr _sdf);
58
61 public: virtual void Load(const std::string &_worldName);
62
64 public: virtual void Init();
65
66 // Documentation inherited
67 protected: virtual bool UpdateImpl(const bool _force);
68
70 protected: virtual void Fini();
71
74 public: unsigned int GetCollisionCount() const;
75
79 public: std::string GetCollisionName(unsigned int _index) const;
80
84 public: unsigned int GetCollisionContactCount(
85 const std::string &_collisionName) const;
86
125 public: msgs::Contacts Contacts() const;
126
130 public: std::map<std::string, physics::Contact> Contacts(
131 const std::string &_collisionName) const;
132
133 // Documentation inherited.
134 public: virtual bool IsActive() const;
135
137 private: void OnContacts(ConstContactsPtr &_msg);
138
141 private: std::unique_ptr<ContactSensorPrivate> dataPtr;
142 };
144 }
145}
146#endif
sensors
Definition SensorManager.hh:35
Contact sensor.
Definition ContactSensor.hh:46
virtual void Fini()
Finalize the sensor.
virtual ~ContactSensor()
Destructor.
virtual void Init()
Initialize the sensor.
unsigned int GetCollisionCount() const
Get the number of collisions that the sensor is observing.
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf)
Load the sensor with SDF parameters.
std::map< std::string, physics::Contact > Contacts(const std::string &_collisionName) const
Gets contacts of a collision.
virtual void Load(const std::string &_worldName)
Load the sensor with default parameters.
std::string GetCollisionName(unsigned int _index) const
Get a collision name at index _index.
virtual bool IsActive() const
Returns true if sensor generation is active.
unsigned int GetCollisionContactCount(const std::string &_collisionName) const
Return the number of contacts for an observed collision.
msgs::Contacts Contacts() const
Get all the contacts for the ContactSensor.
virtual bool UpdateImpl(const bool _force)
This gets overwritten by derived sensor types.
Base class for sensors.
Definition Sensor.hh:53
Forward declarations for the common classes.
Definition Animation.hh:27