##

ContactSensor.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_SENSORS_CONTACTSENSOR_HH_
#define _GAZEBO_SENSORS_CONTACTSENSOR_HH_
#include <map>
#include <string>
#include <memory>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/sensors/Sensor.hh"
#include "gazebo/physics/Contact.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace sensors
{
// Forward declare private data class
class ContactSensorPrivate;
class GZ_SENSORS_VISIBLE ContactSensor: public Sensor
{
public: ContactSensor();
public: virtual ~ContactSensor();
public: virtual void Load(const std::string &_worldName,
sdf::ElementPtr _sdf);
public: virtual void Load(const std::string &_worldName);
public: virtual void Init();
// Documentation inherited
protected: virtual bool UpdateImpl(const bool _force);
protected: virtual void Fini();
public: unsigned int GetCollisionCount() const;
public: std::string GetCollisionName(unsigned int _index) const;
public: unsigned int GetCollisionContactCount(
const std::string &_collisionName) const;
public: msgs::Contacts Contacts() const;
public: std::map<std::string, physics::Contact> Contacts(
const std::string &_collisionName) const;
// Documentation inherited.
public: virtual bool IsActive() const;
private: void OnContacts(ConstContactsPtr &_msg);
private: std::unique_ptr<ContactSensorPrivate> dataPtr;
};
}
}
#endif
gazebo::sensors::ContactSensor::UpdateImpl
virtual bool UpdateImpl(const bool _force)
This gets overwritten by derived sensor types.
gazebo::sensors::ContactSensor
Contact sensor. This sensor detects and reports contacts between objects.
Definition: ContactSensor.hh:45
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::sensors::ContactSensor::Load
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf)
Load the sensor with SDF parameters.
sensors
sensors
Definition: SensorManager.hh:35
system.hh
gazebo::sensors::ContactSensor::~ContactSensor
virtual ~ContactSensor()
Destructor.
msgs.hh
gazebo::sensors::ContactSensor::GetCollisionContactCount
unsigned int GetCollisionContactCount(const std::string &_collisionName) const
Return the number of contacts for an observed collision.
gazebo::sensors::ContactSensor::GetCollisionName
std::string GetCollisionName(unsigned int _index) const
Get a collision name at index _index.
Sensor.hh
gazebo::sensors::ContactSensor::Contacts
msgs::Contacts Contacts() const
Get all the contacts for the ContactSensor.
gazebo::sensors::ContactSensor::ContactSensor
ContactSensor()
Constructor.
gazebo::sensors::ContactSensor::Init
virtual void Init()
Initialize the sensor.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::sensors::ContactSensor::Fini
virtual void Fini()
Finalize the sensor.
gazebo::sensors::Sensor
Base class for sensors.
Definition: Sensor.hh:51
Contact.hh
gazebo::sensors::ContactSensor::IsActive
virtual bool IsActive() const
Returns true if sensor generation is active.
gazebo::sensors::ContactSensor::GetCollisionCount
unsigned int GetCollisionCount() const
Get the number of collisions that the sensor is observing.