API Reference
ROS Type Generation
#
RobotOS.@rosimport
— Macro.
@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.rostypegen
— Function.
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.rostypereset
— Function.
rostypereset()
Clear out the previous @rosimport
s, returning the type generation to its original state. Cannot do anything about already generated modules in Main
.
Publishing and Subscribing
#
RobotOS.Publisher
— Type.
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.publish
— Function.
publish(p::Publisher{T}, msg::T)
Publish msg
on p
, a Publisher
with matching message type.
#
RobotOS.Subscriber
— Type.
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.Service
— Type.
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.ServiceProxy
— Type.
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_service
— Function.
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_node
— Function.
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_shutdown
— Function.
is_shutdown()
Return the shutdown status of the node.
#
RobotOS.spin
— Function.
spin()
Block execution and process callbacks/service calls until the node is shut down.
Time Handling
#
RobotOS.Time
— Type.
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.Duration
— Type.
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.Rate
— Type.
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_sec
— Function.
to_sec(t)
Return the value of a ROS time object in absolute seconds (with nanosecond precision)
#
RobotOS.to_nsec
— Function.
to_nsec(t)
Return the value of a ROS time object in nanoseconds as an integer.
#
RobotOS.now
— Function.
RobotOS.now()
Return the current ROS time as a Time
object.
#
RobotOS.get_rostime
— Function.
get_rostime()
Return the current ROS time as a Time
object.
#
RobotOS.rossleep
— Function.
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.sleep
— Function.
sleep(t::Duration), sleep(t::Rate)
Call rossleep
with a Duration
or Rate
object. Use rossleep
to specify sleep time directly.
Parameters
#
RobotOS.get_param
— Function.
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_param
— Function.
set_param(param_name, val)
Set the value of a parameter on the parameter server.
#
RobotOS.has_param
— Function.
has_param(param_name)
Return a boolean specifying if a parameter exists on the parameter server.
#
RobotOS.delete_param
— Function.
delete_param(param_name)
Delete a parameter from the parameter server. Throws a KeyError
if no such parameter exists.
Logging
#
RobotOS.logdebug
— Function.
logdebug, loginfo, logwarn, logerr, logfatal
Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.
#
RobotOS.loginfo
— Function.
logdebug, loginfo, logwarn, logerr, logfatal
Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.
#
RobotOS.logwarn
— Function.
logdebug, loginfo, logwarn, logerr, logfatal
Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.
#
RobotOS.logerr
— Function.
logdebug, loginfo, logwarn, logerr, logfatal
Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.
#
RobotOS.logfatal
— Function.
logdebug, loginfo, logwarn, logerr, logfatal
Call the rospy logging system at the corresponding message level, passing a message and other arguments directly.