Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change a model's appeareance within IGNITION Gazebo

Dear Ignition Community,

within the former Gazebo Framework, it has been able to change a model's appeareance by declaring different materials, e.g.

material green_on
{
technique
{
  pass
  {
     lighting on

     ambient 0.08207 0.64 0.040269 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0.08207 0.64 0.040269 1
  }
}
}
material green_off
{
technique
{
  pass
  {
     lighting on

     ambient 0.3 0.3 0.3 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0 0 0 1
  }
}
}

and then switching between those materials using dedicated messages within a ModelPlugin node's namespace, such as follows:

 // Message for changing the visual appearance (setting visual states)
this->dataPtr->visualPub   = this->dataPtr->node->Advertise<gazebo::msgs::Visual>("~/visual");
[...]

gazebo::msgs::Visual greenChangeMessage;
greenChangeMessage.set_parent_name(this->model->GetName());
greenChangeMessage.set_name(this->model->GetName() + "::green_light");
if(_green) {
   greenChangeMessage.mutable_material()->mutable_script()->set_name("green_on");
 } else {
  greenChangeMessage.mutable_material()->mutable_script()->set_name("green_off");
 }
this->dataPtr->visualPub->Publish(redChangeMessage);

This approach seems to be outdated for IGNITION Gazebo (e.g. fortress), is there another way to go for such functionalities? IGNITION Gazebo seems to have similar Visual message [2] ready for such types of application, but *.material files are not supported any more [1].

Regards and thx!

[1] https://ignitionrobotics.org/api/gazebo/6.0/migrationsdf.html

[2] https://ignitionrobotics.org/api/msgs/6.4/classignition_1_1msgs_1_1Visual.html

Change a model's appeareance within IGNITION Gazebo

Dear Ignition Community,

within i am looking for an approach to change a model's, resp. it's visual geometry's appeareance during runtime.

Within the former Gazebo Framework, simulation, it has been able to change a model's appeareance by declaring different materials, e.g.

material green_on
{
technique
{
  pass
  {
     lighting on

     ambient 0.08207 0.64 0.040269 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0.08207 0.64 0.040269 1
  }
}
}
material green_off
{
technique
{
  pass
  {
     lighting on

     ambient 0.3 0.3 0.3 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0 0 0 1
  }
}
}

and then switching between those materials using dedicated messages within a ModelPlugin node's namespace, such as follows:

 // Message for changing the visual appearance (setting visual states)
this->dataPtr->visualPub   = this->dataPtr->node->Advertise<gazebo::msgs::Visual>("~/visual");
[...]

gazebo::msgs::Visual greenChangeMessage;
greenChangeMessage.set_parent_name(this->model->GetName());
greenChangeMessage.set_name(this->model->GetName() + "::green_light");
if(_green) {
   greenChangeMessage.mutable_material()->mutable_script()->set_name("green_on");
 } else {
  greenChangeMessage.mutable_material()->mutable_script()->set_name("green_off");
 }
this->dataPtr->visualPub->Publish(redChangeMessage);

This approach seems to be outdated for IGNITION Gazebo (e.g. fortress), is there another way to go for such functionalities? IGNITION Gazebo seems to have similar Visual message [2] ready for such types of application, but *.material files are not supported any more [1].

As stated in [3], the rendering API only affects one of the three "worlds". Since i want to change the model's appeareance, so that the GUI (affecting the user), but also server (for sensors) and client are affected in the same way, i am dependent on a synchronized change.

Regards and thx!

[1] https://ignitionrobotics.org/api/gazebo/6.0/migrationsdf.html

[2] https://ignitionrobotics.org/api/msgs/6.4/classignition_1_1msgs_1_1Visual.html

[3] https://ignitionrobotics.org/api/gazebo/6.1/rendering_plugins.html

Change a model's appeareance within IGNITION Gazebo

Dear Ignition Community,

i am looking for an approach to change a model's, resp. it's visual geometry's appeareance during runtime.

Within the former Gazebo simulation, it has been able to change a model's appeareance by declaring different materials, e.g.

material green_on
{
technique
{
  pass
  {
     lighting on

     ambient 0.08207 0.64 0.040269 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0.08207 0.64 0.040269 1
  }
}
}
material green_off
{
technique
{
  pass
  {
     lighting on

     ambient 0.3 0.3 0.3 1
     diffuse 0.08207 0.64 0.040269 1
     emissive 0 0 0 1
  }
}
}

and then switching between those materials using dedicated messages within a ModelPlugin node's namespace, such as follows:

 // Message for changing the visual appearance (setting visual states)
this->dataPtr->visualPub   = this->dataPtr->node->Advertise<gazebo::msgs::Visual>("~/visual");
[...]

gazebo::msgs::Visual greenChangeMessage;
greenChangeMessage.set_parent_name(this->model->GetName());
greenChangeMessage.set_name(this->model->GetName() + "::green_light");
if(_green) {
   greenChangeMessage.mutable_material()->mutable_script()->set_name("green_on");
 } else {
  greenChangeMessage.mutable_material()->mutable_script()->set_name("green_off");
 }
this->dataPtr->visualPub->Publish(redChangeMessage);

This approach seems to be outdated for IGNITION Gazebo (e.g. fortress), is there another way to go for such functionalities? IGNITION Gazebo seems to have similar Visual message [2] ready for such types of application, but *.material files are not supported any more [1].

As stated in [3], the rendering API only affects one of the three both "worlds". Since i want to change the model's appeareance, so that the GUI (affecting the user), but also the server (for sensors) and client are affected in the same way, i am dependent on a synchronized change.

Regards and thx!

[1] https://ignitionrobotics.org/api/gazebo/6.0/migrationsdf.html

[2] https://ignitionrobotics.org/api/msgs/6.4/classignition_1_1msgs_1_1Visual.html

[3] https://ignitionrobotics.org/api/gazebo/6.1/rendering_plugins.html