API Reference

ROS Type Generation

# RobotOS.@rosimportMacro.

@rosimport

Import ROS message or service types into Julia. Call rostypegen() after all @rosimport calls. Package or type dependencies are also imported automatically as needed.

Example usages:

  @rosimport geometry_msgs.msg.PoseStamped
  @rosimport sensor_msgs.msg: Image, Imu
  @rosimport nav_msgs.srv.GetPlan

# RobotOS.rostypegenFunction.

rostypegen(rosrootmod::Module=Main)

Initiate the Julia type generation process after importing some ROS types. Creates modules in rootrosmod (default is Main) with the same behavior as imported ROS modules in python. Should only be called once, after all @rosimport statements are done.

# RobotOS.rostyperesetFunction.

rostypereset()

Clear out the previous @rosimports, returning the type generation to its original state. Cannot do anything about already generated modules in Main.

Publishing and Subscribing

# RobotOS.PublisherType.

Publisher{T}(topic; kwargs...)
Publisher(topic, T; kwargs...)

Create an object to publish messages of type T on a topic. Keyword arguments are directly passed to rospy.

# RobotOS.publishFunction.

publish(p::Publisher{T}, msg::T)

Publish msg on p, a Publisher with matching message type.

# RobotOS.SubscriberType.

Subscriber{T}(topic, callback, cb_args=(); kwargs...)
Subscriber(topic, T, callback, cb_args=(); kwargs...)

Create a subscription to a topic with message type T with a callback to use when a message is received, which can be any callable type. Extra arguments provided to the callback when invoked can be provided in the cb_args tuple. Keyword arguments are directly passed to rospy.

Services

# RobotOS.ServiceType.

Service{T}(name, callback; kwargs...)
Service(name, T, callback; kwargs...)

Create a service object that can receive requests and provide responses. The callback can be of any callable type. Keyword arguments are directly passed to rospy.

# RobotOS.ServiceProxyType.

ServiceProxy{T}(name; kwargs...)
ServiceProxy(name, T; kwargs...)

Create a proxy object used to invoke a remote service. Use srv_proxy(msg_request) with the object to invoke the service call. Keyword arguments are directly passed to rospy.

# RobotOS.wait_for_serviceFunction.

wait_for_service(srv_name; kwargs...)

Block until the specified service is available. Keyword arguments are directly passed to rospy. Throws an exception if the waiting timeout period is exceeded.

General ROS Functions

# RobotOS.init_nodeFunction.

init_node(name; args...)

Initialize this node, registering it with the ROS master. All arguments are passed on directly to the rospy init_node function.

# RobotOS.is_shutdownFunction.

is_shutdown()

Return the shutdown status of the node.

# RobotOS.spinFunction.

spin()

Block execution and process callbacks/service calls until the node is shut down.

Time Handling

# RobotOS.TimeType.

Time(secs, nsecs), Time(), Time(t::Real)

Object representing an absolute time from a fixed past reference point at nanosecond precision.

Basic arithmetic can be performed on combinations of Time and Duration objects that make sense. For example, if t::Time and d::Duration, t+d will be a Time, d+d a Duration, t-d a Time, d-d a Duration, and t-t a Duration.

# RobotOS.DurationType.

Duration(secs, nsecs), Duration(), Duration(t::Real)

Object representing a relative period of time at nanosecond precision.

Basic arithmetic can be performed on combinations of Time and Duration objects that make sense. For example, if t::Time and d::Duration, t+d will be a Time, d+d a Duration, t-d a Time, d-d a Duration, and t-t a Duration.

# RobotOS.RateType.

Rate(hz::Real), Rate(d::Duration)

Used to allow a loop to run at a fixed rate. Construct with a frequency or Duration and use with rossleep or sleep. The rate object will record execution time of other work in the loop and modify the sleep time to compensate, keeping the loop rate as consistent as possible.

# RobotOS.to_secFunction.

to_sec(t)

Return the value of a ROS time object in absolute seconds (with nanosecond precision)

# RobotOS.to_nsecFunction.

to_nsec(t)

Return the value of a ROS time object in nanoseconds as an integer.

# RobotOS.nowFunction.

RobotOS.now()

Return the current ROS time as a Time object.

# RobotOS.get_rostimeFunction.

get_rostime()

Return the current ROS time as a Time object.

# RobotOS.rossleepFunction.

rossleep(t)

Sleep and process callbacks for a number of seconds implied by the type and value of t, which may be a real-value, a Duration object, or a Rate object.

# Base.sleepFunction.

sleep(t::Duration), sleep(t::Rate)

Call rossleep with a Duration or Rate object. Use rossleep to specify sleep time directly.

Parameters

# RobotOS.get_paramFunction.

get_param(param_name, default=nothing)

Request the value of a parameter from the parameter server, with optional default value. If no default is given, throws a KeyError if the parameter cannot be found.

# RobotOS.set_paramFunction.

set_param(param_name, val)

Set the value of a parameter on the parameter server.

# RobotOS.has_paramFunction.

has_param(param_name)

Return a boolean specifying if a parameter exists on the parameter server.

# RobotOS.delete_paramFunction.

delete_param(param_name)

Delete a parameter from the parameter server. Throws a KeyError if no such parameter exists.

Logging

# RobotOS.logdebugFunction.

logdebug, loginfo, logwarn, logerr, logfatal

Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.

# RobotOS.loginfoFunction.

logdebug, loginfo, logwarn, logerr, logfatal

Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.

# RobotOS.logwarnFunction.

logdebug, loginfo, logwarn, logerr, logfatal

Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.

# RobotOS.logerrFunction.

logdebug, loginfo, logwarn, logerr, logfatal

Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.

# RobotOS.logfatalFunction.

logdebug, loginfo, logwarn, logerr, logfatal

Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.