1 Initialization

# Initialize a node
rclpy.init()

# Start a node
rclpy.spin()

# Start a node
rclpy.spin_once()

# Start a node until the work is done
rclpy.spin_until_future_complete()

# Get the executor
rclpy.get_global_executor()

#  Shut down the
rclpy.shutdown()

2 Node

# package
from rclpy.node import Node

# Add waiting
add_waitable

# Count the number of node publishers
count_publishers(topic_name)

# Count the number of node subscribers
count_subscribers(topic_name)

# Destroy the node
destroy_node()

3 Topic

3.1 Publisher

# Create publisher
Node.create_publisher(
    msg_type,                      # data type 
    topic,                             # release name
    qos_profile,                    
)

# Set to active state
assert_liveliness()

# Destroy
destroy()

# Get the number of subscribers of the publisher
get_subscription_count()

# Publish data
publish(msg)

3.2 Subscription

# Create subscriber
Node.create_subscription(
    msg_type,                        # data type
    topic,                            # subscription name
    callback(),                    # Callback function
    qos_profile
)

4 Services

4.1 Client

# Create client
Node.create_client(
    srv_type,                    #
    srv_name,                    #
    qos_profile                #
)

#  Issue a request
call(request)

# Asynchronous request
call_async(request)

# Delete request
remove_pending_request()

# Check if the service is ready
service_is_ready()

# Wait for the service to start
wait_for_service()

4.2 Service

# Create a server
Node.create-service(
    srv_type,
    srv_name,
    qos_profile
)
send_response()

5 Actions

5.1 Action Client

# Direct package
from rclpy.action import ActionClient

ActionClient(
    action_type,
    action_name,
)

# Add wait
add_to_wait_set(wait_set)

# Destroy
destroy()

#  Entity number
get_num_entities()

# Is it ready
is_ready(wait_set)

# Send
send_goal(goal)

# Send asynchronously
send_goal_async()

#Check if the server is ready
server_is_ready()

# Wait for the server to be ready
wait_for_server()

5.2 Action Server

ActionServer(
    action_type,
    action_name,
    callback,
)
# Add wait
add_to_wait_set(wait_set)

# Destroy
destroy()

# Entity number
get_num_entities()

# Is it ready
is_ready(wait_set)

# Send
send_goal(goal)

# Send asynchronously
send_goal_async()

# Check if the server is ready
server_is_ready()

# Wait for the server to be ready
wait_for_server()

6 Timer

# import package
from rclpy.timer import Rate,Timer

Rate(timer,*,context)

Timer(
    callback,
    callback_group,
    timer_period_ns,
    clock,
    *,
    context=None
)
cancel()
destroy()
is_canceled()
is_ready()
reset()
time_since_last_call()
time_until_next_call()

7 Context

init()

ok()

# a callback to be called on shutdown
on_shutdown()

shutdown()

try_shutdown()

results matching ""

    No results matching ""