You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the course of migrating a plugin from Gazebo to Ignition (#80), I needed to subscribe to data published via ign-transport by an IMU sensor. To determine the fully qualified topic name to subscribe to, I ended up jumping through quite some hoops inside PreUpdate():
// This lookup is done in PreUpdate() because in Configure() it's not possible to get the fully qualified topic name we want
if(!this->dataPtr->imuInitialized)
{
// Set unconditionally because we're only going to try this once.
this->dataPtr->imuInitialized = true;
std::string imuTopicName;
_ecm.Each<ignition::gazebo::components::Imu, ignition::gazebo::components::Name>(
[&](const ignition::gazebo::Entity &_imu_entity,
const ignition::gazebo::components::Imu * /*_imu*/,
const ignition::gazebo::components::Name *_name)->bool
{
if(_name->Data() == this->dataPtr->imuName)
{
// The parent of the imu is imu_link
ignition::gazebo::Entity parent = _ecm.ParentEntity(_imu_entity);
this->dataPtr->modelLink = parent;
if(parent != ignition::gazebo::kNullEntity)
{
// The grandparent of the imu is the quad itself, which is where this plugin is attached
ignition::gazebo::Entity gparent = _ecm.ParentEntity(parent);
if(gparent != ignition::gazebo::kNullEntity)
{
ignition::gazebo::Model gparent_model(gparent);
if(gparent_model.Name(_ecm) == this->dataPtr->modelName)
{
imuTopicName = ignition::gazebo::scopedName(_imu_entity, _ecm) + "/imu";
igndbg << "Computed IMU topic to be: " << imuTopicName << std::endl;
}
}
}
}
return true;
});
if(imuTopicName.empty())
{
ignerr << "[" << this->dataPtr->modelName << "] "
<< "imu_sensor [" << this->dataPtr->imuName
<< "] not found, abort ArduPilot plugin." << "\n";
return;
}
this->dataPtr->node.Subscribe(imuTopicName, &ignition::gazebo::systems::ArduPilotPluginPrivate::imuCb, this->dataPtr.get());
}
I don't know what the right answer looks like, but that seems to me too much work to get to a topic name.
The text was updated successfully, but these errors were encountered:
In the course of migrating a plugin from Gazebo to Ignition (#80), I needed to subscribe to data published via
ign-transport
by an IMU sensor. To determine the fully qualified topic name to subscribe to, I ended up jumping through quite some hoops insidePreUpdate()
:I don't know what the right answer looks like, but that seems to me too much work to get to a topic name.
The text was updated successfully, but these errors were encountered: