{ "cells": [ { "cell_type": "markdown", "id": "52b665f0", "metadata": {}, "source": [ "## Tutorial to use ros2 param widgets" ] }, { "cell_type": "code", "execution_count": null, "id": "2fcad052-4631-493b-8dd9-3bf43539bd53", "metadata": {}, "outputs": [], "source": [ "! ../scripts/generate_cling_ros2.py ~/ros2_foxy/install" ] }, { "cell_type": "code", "execution_count": null, "id": "a98ad41b-2fa0-426b-a086-6ea0c826b312", "metadata": {}, "outputs": [], "source": [ "#include \"load_ros2.h\"" ] }, { "cell_type": "code", "execution_count": null, "id": "a5d7c8ff-8ebe-45d6-8354-059e5a342036", "metadata": {}, "outputs": [], "source": [ "#include \"jupyter_ros_utils/ros2_jupyter.hpp\"" ] }, { "cell_type": "markdown", "id": "65c8011e", "metadata": {}, "source": [ "### Start node" ] }, { "cell_type": "code", "execution_count": null, "id": "a59ced7b-0510-4467-8ef1-33cc023f1d8b", "metadata": {}, "outputs": [], "source": [ "auto node = ros_init(); // For some reason, rclcpp::init after shutdown crashes the kernel" ] }, { "cell_type": "code", "execution_count": null, "id": "a313dd25-7d57-44ae-b572-ef4db5891ebe", "metadata": {}, "outputs": [], "source": [ "rclcpp::ok()" ] }, { "cell_type": "code", "execution_count": null, "id": "6474d3fd-e7a1-40b4-b293-1348116cba49", "metadata": {}, "outputs": [], "source": [ "!ros2 node list" ] }, { "cell_type": "markdown", "id": "1c0bb128", "metadata": {}, "source": [ "### Create Widgets\n", "`Set Param` button sets ros2 parameters.
\n", "This parameter starts to be monitored after pressing `Start Waiting` button." ] }, { "cell_type": "code", "execution_count": null, "id": "5b6287ab", "metadata": {}, "outputs": [], "source": [ "auto w1 = node->create_param_widgets();" ] }, { "cell_type": "code", "execution_count": null, "id": "1a1e07eb", "metadata": {}, "outputs": [], "source": [ "auto w2 = node->create_param_widgets();" ] }, { "cell_type": "markdown", "id": "66acadd7", "metadata": {}, "source": [ "### Control Param Widgets\n", "Before running the code below, try to press \"Start Waiting\" on the widgets above.\n", "You'd be able to see the changes from ❌ <-> ✅ after running the `rosparam set` or `rosparam delete`

\n", "\n", "1. Try changing the parameter set in the above w1 widget\n", "2. Try deleting the parameter set in the above w1 widget\n", "3. You can also see the widgets are running independently!" ] }, { "cell_type": "code", "execution_count": null, "id": "8b0d8b13", "metadata": {}, "outputs": [], "source": [ "! ros2 param set /interactive_node /interactive_node/test1 zeus1" ] }, { "cell_type": "code", "execution_count": null, "id": "43ad54c5", "metadata": {}, "outputs": [], "source": [ "! ros2 param delete /interactive_node /interactive_node/test1" ] }, { "cell_type": "code", "execution_count": null, "id": "7858fb44", "metadata": {}, "outputs": [], "source": [ "! ros2 param set /interactive_node /interactive_node/test2 zeus2" ] }, { "cell_type": "code", "execution_count": null, "id": "8fcb4e2a", "metadata": {}, "outputs": [], "source": [ "! ros2 param delete /interactive_node /interactive_node/test2" ] } ], "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 }