This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

rosservice

Retrieve information about services in ROS network

Syntax

rosservice list
rosservice info svcname
rosservice type svcname
rosservice uri svcname
svclist = rosservice("list")
svcinfo = rosservice("info",svcname)
svctype = rosservice("type",svcname)
svcuri = rosservice("uri",svcname)

Description

example

rosservice list returns a list of service names for all of the active service servers on the ROS network.

example

rosservice info svcname returns information about the specified service, svcname.

example

rosservice type svcname returns the service type.

example

rosservice uri svcname returns the URI of the service.

example

svclist = rosservice("list") returns a list of service names for all of the active service servers on the ROS network. svclist contains a cell array of service names.

example

svcinfo = rosservice("info",svcname) returns a structure of information, svcinfo, about the service, svcname.

example

svctype = rosservice("type",svcname) returns the service type of the service as a character vector.

example

svcuri = rosservice("uri",svcname) returns the URI of the service as a character vector.

Examples

collapse all

Connect to the ROS network. Specify the IP address of your specific network.

rosinit('192.168.154.131')
Initializing global node /matlab_global_node_00003 with NodeURI http://192.168.154.1:56056/

List the services available on the ROS master.

rosservice list
/camera/rgb/image_raw/compressed/set_parameters
/camera/set_camera_info
/camera/set_parameters
/gazebo/apply_body_wrench
/gazebo/apply_joint_effort
/gazebo/clear_body_wrenches
/gazebo/clear_joint_forces
/gazebo/delete_model
/gazebo/get_joint_properties
/gazebo/get_link_properties
/gazebo/get_link_state
/gazebo/get_loggers
/gazebo/get_model_properties
/gazebo/get_model_state
/gazebo/get_physics_properties
/gazebo/get_world_properties
/gazebo/pause_physics
/gazebo/reset_simulation
/gazebo/reset_world
/gazebo/set_joint_properties
/gazebo/set_link_properties
/gazebo/set_link_state
/gazebo/set_logger_level
/gazebo/set_model_configuration
/gazebo/set_model_state
/gazebo/set_parameters
/gazebo/set_physics_properties
/gazebo/spawn_gazebo_model
/gazebo/spawn_sdf_model
/gazebo/spawn_urdf_model
/gazebo/unpause_physics
/laserscan_nodelet_manager/get_loggers
/laserscan_nodelet_manager/list
/laserscan_nodelet_manager/load_nodelet
/laserscan_nodelet_manager/set_logger_level
/laserscan_nodelet_manager/unload_nodelet
/mobile_base_nodelet_manager/get_loggers
/mobile_base_nodelet_manager/list
/mobile_base_nodelet_manager/load_nodelet
/mobile_base_nodelet_manager/set_logger_level
/mobile_base_nodelet_manager/unload_nodelet
/robot_state_publisher/get_loggers
/robot_state_publisher/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level

Shut down the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_00003 with NodeURI http://192.168.154.1:56056/

Connect to the ROS network. Specify the IP address of your specific network.

rosinit('192.168.154.131')
Initializing global node /matlab_global_node_76389 with NodeURI http://192.168.154.1:55924/

Get information on the gazebo/pause_physics service.

svcinfo = rosservice('info','gazebo/pause_physics')
svcinfo = 

  struct with fields:

    Node: '/gazebo'
     URI: 'rosrpc://192.168.154.131:33260'
    Type: 'std_srvs/Empty'
    Args: {}

Get the service type.

svctype = rosservice('type','gazebo/pause_physics')
svctype =

    'std_srvs/Empty'

Get the service URI.

svcuri = rosservice('uri','gazebo/pause_physics')
svcuri =

    'rosrpc://192.168.154.131:33260'

Shut down the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_76389 with NodeURI http://192.168.154.1:55924/

Input Arguments

collapse all

Name of service, specified as a string scalar or character vector. The service name must match its name in the ROS network.

Output Arguments

collapse all

Information about a ROS service, returned as a character vector.

List of available ROS services, returned as a cell array of character vectors.

Type of ROS service, returned as a character vector.

URI for accessing service, returned as a character vector.

See Also

|

Introduced in R2015a