{ "cells": [ { "cell_type": "markdown", "id": "f11b455a", "metadata": {}, "source": [ "# The Tutorial shows demonstration of Asynchronous ROS Publisher.\n", "\n" ] }, { "cell_type": "markdown", "id": "67b2e9b0", "metadata": {}, "source": [ "### Step 1 - Get the required header files to run ROS\n", "\n", "NOTE :- Run roscore in on of the other terminal before starting the tutorial to start rosmaster." ] }, { "cell_type": "code", "execution_count": null, "id": "ed60fae6-df8d-4df7-b2db-f3d5f68e7e88", "metadata": {}, "outputs": [], "source": [ "! python3 ../scripts/generate_cling_3rd_party.py roscpp" ] }, { "cell_type": "markdown", "id": "c7638c6f", "metadata": {}, "source": [ "### Step 2 - Load ROS and Boost libraries." ] }, { "cell_type": "code", "execution_count": null, "id": "4fac76ce-8c53-4469-b310-9da425cd9d17", "metadata": {}, "outputs": [], "source": [ "#include \"load_roscpp.h\"" ] }, { "cell_type": "markdown", "id": "5714cfb0", "metadata": {}, "source": [ "### Step 3 - Load ROS Publisher." ] }, { "cell_type": "code", "execution_count": null, "id": "54137c9b-d873-4338-90de-18d4f84b8d5f", "metadata": { "tags": [] }, "outputs": [], "source": [ "#include \"jupyter_ros_utils/ros1_publisher.hpp\"" ] }, { "cell_type": "markdown", "id": "73547d44", "metadata": {}, "source": [ "### Step 4 - Initialize ROS Spinner and start publisher\n", "This widget will use publish data using pub_callback and show it in the stream" ] }, { "cell_type": "code", "execution_count": null, "id": "7f5062d6-4b53-4575-a65d-3e5c09d0f7a7", "metadata": {}, "outputs": [], "source": [ "ros_init(\"cpp_ros_async_callback_publisher\");" ] }, { "cell_type": "code", "execution_count": null, "id": "afafb8ef-0230-4fd0-a315-f4bb61175b3b", "metadata": {}, "outputs": [], "source": [ "#include \n", "\n", "uint32_t data = 0;" ] }, { "cell_type": "code", "execution_count": null, "id": "9fd6a7b3-8b2c-48be-88e5-23f20f063a57", "metadata": {}, "outputs": [], "source": [ "std_msgs::UInt32 pub_callback() {\n", " std_msgs::UInt32 msg;\n", " msg.data = data;\n", " ++data;\n", " ROS_INFO(\"%d\", data);\n", " \n", " return msg;\n", "}" ] }, { "cell_type": "code", "execution_count": null, "id": "ef4a5f5e-3366-49bc-9718-e81968f63a61", "metadata": {}, "outputs": [], "source": [ "ZeusPublisher pub(\"/magic/uint\", pub_callback);" ] } ], "metadata": { "kernelspec": { "display_name": "C++17", "language": "C++17", "name": "xcpp17" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".cpp", "mimetype": "text/x-c++src", "name": "c++", "version": "17" } }, "nbformat": 4, "nbformat_minor": 5 }