Migration from Gazebo-classic: Sensor API
When migrating plugins from Gazebo-classic to Gazebo, developers will notice that the C++ APIs for both simulators are quite different. Be sure to check the plugin migration tutorial to get a high-level view of the architecture differences before using this guide.
This tutorial is meant to serve as a reference guide for developers migrating functions from the gazebo::sensors::Sensor class.
If you're trying to use some API which doesn't have an equivalent on Gazebo yet, feel free to ticket an issue.
Sensor API
Gazebo-classic's gazebo::sensors::Sensor
provides lots of functionality, which can be divided in these categories:
- Properties: Setting / getting properties
- Example: Sensor::Name
- Read family: Getting parent
- Example: Sensor::ParentName
- Write family: Changing parent
- Example: Sensor::SetParent
- Lifecycle: Functions to control the sensor's lifecycle
- Example: Sensor::Init
You'll find the Gazebo APIs below on the following headers:
- ignition/gazebo/Sensor.hh
- ignition/gazebo/Util.hh
- ignition/gazebo/SdfEntityCreator.hh
- ignition/gazebo/EntityComponentManager.hh
It's worth remembering that most of this functionality can be performed using the EntityComponentManager directly.
As an example the Sensor::Pose()
is a convienient function for querying the Pose
component from the EntityComponentManager
, i.e.
The functions presented in the sections below exist for convenience and readability. The items marked as TODO
means that the equivalent API is not implemented yet in Gazebo.
Properties
Most of Gazebo-classic's Sensor API is related to setting and getting properties. These functions are great candidates to have equivalents on Gazebo Gazebo, because the Entity-Component-System architecture is perfect for setting components (properties) into entities such as sensors.
Classic | Gazebo |
---|---|
Category | TODO |
FillMsg | TODO |
Id | ignition::gazebo::Sensor::Entity |
IsActive | TODO |
LastMeasurementTime | TODO |
LastUpdateTime | TODO |
Name | ignition::gazebo::Sensor::Name |
NextRequiredTimestamp | TODO |
Noise | TODO |
Pose | ignition::gazebo::Sensor::Pose |
ResetLastUpdateTime | TODO |
ScopedName | ignition::gazebo::scopedName |
SetActive | TODO |
SetPose | TODO |
SetUpdateRate | TODO |
Topic | ignition::gazebo::Sensor::Topic |
Type | ignition::gazebo::entityType |
UpdateRate | TODO |
Visualize | TODO |
WorldName | ignition::gazebo::worldEntity |
Read family
These APIs deal with reading information related to parent relationship.
The main difference in these APIs across Gazebo generations is that on classic, they deal with shared pointers to entities, while on Gazebo, they deal with entity IDs.
Classic | Gazebo |
---|---|
ParentId | ignition::gazebo::Sensor::Parent |
ParentName | ignition::gazebo::Sensor::Parent |
Write family
These functions deal with modifying the entity tree, attaching children to new parents.
Classic | Gazebo |
---|---|
SetParent | TODO |
Lifecycle
These functions aren't related to the state of a sensor, but perform some processing related to the sensor's lifecycle, like initializing, updating or terminating it.
Classic | Gazebo |
---|---|
ConnectUpdated | TODO |
Fini | N/A |
Init | N/A |
Load | ignition::gazebo::SdfEntityCreator::CreateEntities |
Update | Entities are updated by systems |