Skip to content

Commit

Permalink
Remove last mentions of txROS from API documentation, fix spelling mi…
Browse files Browse the repository at this point in the history
…stakes in axros documentation (#1158)
  • Loading branch information
cbrxyz authored Mar 18, 2024
1 parent 2212dc6 commit db8890d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions docs/reference/axros/examples.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Examples
^^^^^^^^

The following example starts a sublisher and a subscriber which listens to the messages
sublished by the sublisher. After two seconds, it reports how many messages it was
The following example starts a publisher and a subscriber which listens to the messages
published by the publisher. After two seconds, it reports how many messages it was
able to successfully receive.

.. code-block:: python
import asyncio
from rosgraph_msgs.msg import Clock
from axros import NodeHandle, sublisher, Subscriber
from axros import NodeHandle, Publisher, Subscriber
import uvloop
async def subsub(nh: NodeHandle, sub: sublisher, sub: Subscriber):
async def pubsub(nh: NodeHandle, pub: Publisher, sub: Subscriber):
count = 0
try:
while True:
await asyncio.sleep(0)
msg = (Clock(nh.get_time()))
sub.sublish(msg)
pub.publish(msg)
recv = await sub.get_next_message()
if (recv == msg):
count += 1
Expand All @@ -30,13 +30,13 @@ able to successfully receive.
async def main():
nh = await NodeHandle.from_argv("node", "", anonymous = True)
async with nh:
sub = nh.advertise('clock2', Clock, latching = True)
pub = nh.advertise('clock2', Clock, latching = True)
sub = nh.subscribe('clock2', Clock)
await asyncio.gather(sub.setup(), sub.setup())
subsub_task = asyncio.create_task(subsub(nh, sub, sub))
await asyncio.gather(pub.setup(), sub.setup())
pubsub_task = asyncio.create_task(pubsub(nh, pub, sub))
print("Everything is setup. Waiting two seconds.")
await asyncio.sleep(2)
subsub_task.cancel()
pubsub_task.cancel()
if __name__ == "__main__":
uvloop.install()
Expand All @@ -62,28 +62,28 @@ The node handle can be used for general purposes, such as parameters and sleepin
This parameter does not exist!
>>> await nh.sleep(2) # Sleeps for 2 seconds
The node handle can also be used for sublishing and subscribing to topics. Note
that all sublishers and subscribers must be setup.
The node handle can also be used for publishing and subscribing to topics. Note
that all Publishers and subscribers must be setup.

.. code-block:: python
>>> import os
>>> import axros
>>> nh = await axros.NodeHandle("/test", "special_node", "localhost", os.environ["ROS_MASTER_URI"], {})
>>> from std_msgs.msg import Int32
>>> sub = nh.advertise("running_time", Int32)
>>> await sub.setup()
>>> async def sublish():
>>> pub = nh.advertise("running_time", Int32)
>>> await pub.setup()
>>> async def publish():
... try:
... count = 0
... while True:
... sub.sublish(Int32(count))
... pub.publish(Int32(count))
... count += 1
... await asyncio.sleep(1)
... except asyncio.CancelledError as _:
... # When task gets cancelled, stop sublishing
... # When task gets cancelled, stop publishing
... pass
>>> task = asyncio.create_task(sublish()) # Start sublishing!
>>> task = asyncio.create_task(publish()) # Start publishing!
>>> sub = nh.subscribe("running_time", Int32)
>>> await sub.setup()
>>> while True:
Expand Down

0 comments on commit db8890d

Please sign in to comment.