# Revision history [back]

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly?

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

terminate called after throwing an instance of 'j2pb_error' what(): Unknown field: visibility Aborted (core dumped)

)

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly?

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

 terminate called after throwing an instance of 'j2pb_error'
what():  Unknown field: visibility
Aborted (core dumped)dumped)


)

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

This is using Gazebo 2.2.3

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly?

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

  terminate called after throwing an instance of 'j2pb_error'
what():  Unknown field: visibility
Aborted (core dumped)


)

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

This is using Gazebo 2.2.3

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly?incorrectly? In the World tab I see Model | sensor_head | sensor_head_rotation_link, the Property for clicking on that shows the name as sensor_head::sensor_head_rotation_link

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

  terminate called after throwing an instance of 'j2pb_error'
what():  Unknown field: visibility
Aborted (core dumped)


)

### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

This is using Gazebo 2.2.3

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly? In the World tab I see Model | sensor_head | sensor_head_rotation_link, the Property for clicking on that shows the name as sensor_head::sensor_head_rotation_link

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

  terminate called after throwing an instance of 'j2pb_error'
what():  Unknown field: visibility
Aborted (core dumped)


)

Pursuing the C++ Approach:

If I use the following code, launch gazebo and create a box called unit_box_1, running ./visibility unit_box_1 link still doesn't produce any visual changes.

visibility.cpp:

int main(int argn, char** argv)
{
gazebo::setupClient(argn, argv);

if (argn >= 3)
{
parent_name = argv[1];
name = argv[2];
}

gazebo::transport::NodePtr node(new gazebo::transport::Node());
node->Init();

// gztopic echo /gazebo/default/visual shows this
gazebo::transport::PublisherPtr pub =

std::cout << "waiting for connection" << std::endl;
pub->WaitForConnection();

double transparency = 1.0;
bool visible = true;

gazebo::msgs::Visual msg;
msg.set_parent_name(parent_name);
msg.set_name(name);
std::cout << "parent " << parent_name << ", name " << name << std::endl;

while (true)
{
msg.set_transparency(transparency);
msg.set_visible(visible);
//std::cout << "transparency " << transparency << std::endl;
pub->Publish(msg);

visible = !visible;
transparency = 1.0 - transparency;

sleep(2.0);
}

gazebo::shutdown();

return 0;
}


### Toggle visibility of a link?

Ideally I could publish a message from ROS that would set the transparency of a specified link to any value.

Would I have to write a custom plugin?

Pursuing the gazebojs approach:

This is using Gazebo 2.2.3

I've gone through

One note is that npm install installs node_modules to the current directory, I moved it to a better location and the require below is the relative path to it::

  var gazebojs = require('./npm/node_modules/gazebojs')
var gazebo = new gazebojs.Gazebo()
gazebo.publish('gazebo.msgs.Visual', '~/Visual', msg);


But the link stays visible. Am I missing something else required to turn the visibility off? I assume leaving out all the optional fields except 'visible' in the protobuf is fine.

If I put garbage into the parent_name or name fields there are no errors. Am I using those fields incorrectly? In the World tab I see Model | sensor_head | sensor_head_rotation_link, the Property for clicking on that shows the name as sensor_head::sensor_head_rotation_link

(I have it correct above but if the msg has a problem it mostly results in an error that crashes node like::

  terminate called after throwing an instance of 'j2pb_error'
what():  Unknown field: visibility
Aborted (core dumped)


)

Pursuing the C++ Approach:

If I use the following code, launch gazebo and create a box called unit_box_1, running ./visibility unit_box_1 link link still doesn't produce any visual changes.

visibility.cpp:

int main(int argn, char** argv)
{
gazebo::setupClient(argn, argv);

if (argn >= 3)
{
parent_name = argv[1];
name = argv[2];
}

gazebo::transport::NodePtr node(new gazebo::transport::Node());
node->Init();

// gztopic echo /gazebo/default/visual shows this
gazebo::transport::PublisherPtr pub =

std::cout << "waiting for connection" << std::endl;
pub->WaitForConnection();

double transparency = 1.0;
bool visible = true;

gazebo::msgs::Visual msg;
msg.set_parent_name(parent_name);
msg.set_name(name);
std::cout << "parent " << parent_name << ", name " << name << std::endl;

while (true)
{
msg.set_transparency(transparency);
msg.set_visible(visible);
//std::cout << "transparency " << transparency << std::endl;
pub->Publish(msg);

visible = !visible;
transparency = 1.0 - transparency;

sleep(2.0);
}

gazebo::shutdown();

return 0;
}