void ThrusterTask::setGazeboModel( ModelPtr model )
{
    string taskName = "gazebo:" + model->GetWorld()->GetName() + ":" + model->GetName() + ":gazebo_thruster";
    provides()->setName(taskName);
    _name.set(taskName);

    topicName = model->GetName() + "/thrusters";
} 
Пример #2
0
void RockBridge::instantiateSensorComponents(sdf::ElementPtr modelElement, ModelPtr model)
{
    sdf::ElementPtr linkElement = modelElement->GetElement("link");
    while( linkElement ){
        sdf::ElementPtr sensorElement = linkElement->GetElement("sensor");
        while( sensorElement ){
            string sensorName = sensorElement->Get<string>("name");
            string sensorType = sensorElement->Get<string>("type");
            // To support more sensors, test for different sensors types
            if( sensorType == "ray" )
            {
                gzmsg << "RockBridge: creating laser line component: " + sensorName << endl;
                LaserScanTask* laser_line_task = new LaserScanTask();
                string topicName = model->GetName() + "/" + linkElement->Get<string>("name") + "/" + sensorName + "/scan";
                laser_line_task->setGazeboModel( model, sensorName, topicName );
                setupTaskActivity( laser_line_task );
            }
            else if(sensorType == "camera")
            {
                gzmsg << "RockBridge: creating camera component: " + sensorName << endl;
                CameraTask* camera = new CameraTask();
                string topicName = model->GetName() + "/" + linkElement->Get<string>("name") + "/" + sensorName + "/image";
                camera->setGazeboModel(model, sensorName, topicName);
                setupTaskActivity(camera);
            }
            else if(sensorType == "imu")
            {
                gzmsg << "RockBridge: creating imu component: " + sensorName << endl;
                ImuTask *imu = new ImuTask();
                string topicName = model->GetName() + "/" + linkElement->Get<string>("name") + "/" + sensorName + "/imu";
                imu->setGazeboModel(model, sensorName, topicName);
                setupTaskActivity(imu);
            }

            sensorElement = sensorElement->GetNextElement("sensor");
        }
        linkElement = linkElement->GetNextElement("link");
    }
}