Ver código fonte

moved an removed files

Jens Ogorek 1 ano atrás
pai
commit
d8edb729be

+ 0 - 25
examples/nicegui_ros2/basic_example/Dockerfile

@@ -1,25 +0,0 @@
-FROM ros:humble-ros-base
-
-RUN apt-get update && apt-get install -y \
-    python3-pip \
-    python3-dev \
-    build-essential 
-
-SHELL ["/bin/bash", "-c"]
-
-RUN pip3 install nicegui
-
-EXPOSE 8000
-
-COPY ros2_ws ros2_ws/
-
-RUN cd ros2_ws && \
-    source /opt/ros/humble/setup.bash && \
-    colcon build --symlink-install
-
-COPY basic_example/ros_entrypoint.sh /
-
-ENTRYPOINT ["/ros_entrypoint.sh"]
-
-CMD ["bash"]
-

+ 0 - 11
examples/nicegui_ros2/basic_example/docker-compose.yml

@@ -1,11 +0,0 @@
-version: '3'
-services:
-  basic_example:
-    build:
-      context: ../
-      dockerfile: basic_example/Dockerfile
-    ports:
-      - 8000:8000
-    volumes:
-      - ../ros2_ws/src:/ros2_ws/src
-    command: ros2 run nicegui_ros2 basic_nicegui

+ 0 - 8
examples/nicegui_ros2/basic_example/ros_entrypoint.sh

@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-
-source /opt/ros/humble/setup.bash
-source /ros2_ws/install/setup.bash
-cd /ros2_ws
-
-exec "$@"

+ 0 - 25
examples/nicegui_ros2/joystick_example/Dockerfile

@@ -1,25 +0,0 @@
-FROM ros:humble-ros-base
-
-RUN apt-get update && apt-get install -y \
-    python3-pip \
-    python3-dev \
-    build-essential 
-
-SHELL ["/bin/bash", "-c"]
-
-RUN pip3 install nicegui
-
-EXPOSE 8000
-
-COPY ros2_ws ros2_ws/
-
-RUN cd ros2_ws && \
-    source /opt/ros/humble/setup.bash && \
-    colcon build --symlink-install
-
-COPY basic_example/ros_entrypoint.sh /
-
-ENTRYPOINT ["/ros_entrypoint.sh"]
-
-CMD ["bash"]
-

+ 0 - 21
examples/nicegui_ros2/joystick_example/docker-compose.yml

@@ -1,21 +0,0 @@
-version: '3'
-services:
-  joystick_example:
-    build:
-      context: ../
-      dockerfile: basic_example/Dockerfile
-    ports:
-      - 8000:8000
-    volumes:
-      - ../ros2_ws/src:/ros2_ws/src
-    command: ros2 run nicegui_ros2 joystick_nicegui
-
-  turtle_sim:
-    image: osrf/ros:humble-desktop
-    environment: 
-      - DISPLAY
-    volumes: 
-      - /tmp/.X11-unix:/tmp/.X11-unix:rw
-    command: ros2 run turtlesim turtlesim_node
-    depends_on:
-      - joystick_example

+ 0 - 8
examples/nicegui_ros2/joystick_example/ros_entrypoint.sh

@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-
-source /opt/ros/humble/setup.bash
-source /ros2_ws/install/setup.bash
-cd /ros2_ws
-
-exec "$@"

+ 0 - 48
examples/nicegui_ros2/readme.md

@@ -1,48 +0,0 @@
-# Simple NiceGUI example
-The example is based on ROS2's Minimal Publisher, that is controlled by NiceGUI's app.on_startup function. You can see and access the published message on the /topic topic and see the simple visualization of NiceGUI on 127.0.0.1:8000. If you change some part of the code and save it, you can immediately see the change without restarting the node.
-
-## Run
-Starting from the `nicegui_ros2/basic_example` folder:
-
-```bash
-docker compose up 
-```
-
-# Nicegui Joystick and Turtlesim
-Like the simple example, ROS2 itself is controlled by the app.on_startup function. Everything works like the Simple NiceGUI example, but this time the UI on the local webpage will display a joystick. 
-If you are running the Node from the provided Docker, it will start a second Docker with the turtlesim_node already running. 
-Note: Keep in mind that the provided Docker composition is for usage within an Ubuntu system. If you are running it somewhere else, you might have to change the .yml file. These changes are related to the visualization of the turtlesim_node
-
-## Run
-Before Running the Docker, you have to configure your xhost like this: 
-
-```bash
-xhost local:root
-```
-
- Starting from the `nicegui_ros2/joystick_example` folder:
-
-```bash
-docker compose up 
-```
-
-If you want to run the turtlesim_node locally and just run the joystick from Docker:
-
-```bash
-docker compose up joystick_example
-```
-
-## Run information
-The parameter `uvicorn_reload_dirs` will define which files trigger a reload on change. The path is automatically detected.
-
-## Without Docker
-If you want to run the Nodes locally in your ROS2 environment, you can copy the Nodes from the ros2_ws/src folder. 
-To run it, just use the normal ros2 run:
-
-```bash
-ros2 run nicegui_ros2 basic_nicegui
-```
-or 
-```bash
-ros2 run nicegui_ros2 joystick_nicegui
-```

+ 0 - 0
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/nicegui_ros2/__init__.py


+ 0 - 50
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/nicegui_ros2/basic_nicegui.py

@@ -1,50 +0,0 @@
-import rclpy
-from rclpy.executors import ExternalShutdownException
-from rclpy.node import Node
-from std_msgs.msg import String
-import threading
-from nicegui import ui, app, run
-from pathlib import Path
-
-
-
-class MinimalPublisher(Node):
-    """This is a minimal publisher example from the ROS2 tutorials integrated with NiceGUI.
-
-    https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html
-    """
-
-    def __init__(self) -> None:
-        super().__init__('minimal_publisher')
-        self.publisher_ = self.create_publisher(String, 'topic', 10)
-        timer_period = 0.5  # seconds
-        self.timer = self.create_timer(timer_period, self.timer_callback)
-        self.i = 0
-
-    def timer_callback(self) -> None:
-        msg = String()
-        msg.data = 'Hello World: %d' % self.i
-        self.publisher_.publish(msg)
-        self.get_logger().info('Publishing: "%s"' % msg.data)
-        self.i += 1
-
-
-def ros_main() -> None:
-    print('Starting ROS2...', flush=True)
-    rclpy.init()
-    minimal_publisher_node = MinimalPublisher()
-    try:
-        rclpy.spin(minimal_publisher_node)
-    except ExternalShutdownException:
-        print('ROS2 was shutdown by NiceGUI.')
-
-@ui.page('/')
-def page():
-    ui.label('Hello NiceGUI!')
-
-def main():
-    pass # NOTE: This is originally used as the ROS entry point, but we give the controll of the node to NiceGUI.
-
-app.on_startup(lambda: threading.Thread(target=ros_main).start())
-run.APP_IMPORT_STRING = f'{__name__}:app'
-ui.run(port=8000, uvicorn_reload_dirs=str(Path(__file__).parent.resolve()))

+ 0 - 82
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/nicegui_ros2/joystick_nicegui.py

@@ -1,82 +0,0 @@
-import rclpy
-from rclpy.executors import ExternalShutdownException
-from rclpy.node import Node
-from geometry_msgs.msg import Twist
-import threading
-from nicegui import ui, app, run
-from pathlib import Path
-
-class MinimalPublisher(Node):
-    linear = 0.0
-    angular = 0.0
-
-    def __init__(self) -> None:
-        super().__init__('turtlesim_joystick')
-        self.publisher_ = self.create_publisher(Twist, 'turtle1/cmd_vel', 1)
-        timer_period = 0.2  # seconds
-        self.timer = self.create_timer(timer_period, self.timer_callback)
-
-    def timer_callback(self) -> None:
-        msg = Twist()
-        self.get_logger().info('Publishing-> linear: "%f", angular: "%f"' % (self.linear, self.angular))
-        msg.linear.x = float(self.linear)
-        msg.angular.z = float(-self.angular)
-        self.publisher_.publish(msg)
-
-    @classmethod
-    def update(cls, x, y) -> None:
-        cls.linear = x
-        cls.angular = y
-
-def ros_main() -> None:
-    print('Starting ROS2...', flush=True)
-    rclpy.init()
-    minimal_publisher_node = MinimalPublisher()
-    try:
-        rclpy.spin(minimal_publisher_node)
-    except ExternalShutdownException:
-        print('ROS2 was shutdown by NiceGUI.')
-
-@ui.page('/')
-def page() -> None:
-    with ui.row().classes('items-stretch'):
-
-        with ui.card():
-
-            ui.markdown('''
-                ## Guide
-
-                This is a simple virtual joystick <br>
-                that sends twist commands to turtlesim.<br><br>
-                To control the turtle, just klick inside the blue <br>
-                field and drag your mouse around.<br><br>
-                If your linar & angular values gets stuck, just <br>
-                click once inside the joystick field.
-            ''')
-
-        with ui.card():
-            ui.markdown('### Turtlebot3 Joystick')
-
-            # NOTE: Joystick will be reworked in the future, so this is a temporary workaround for the size.
-            ui.add_head_html('<style>.my-joystick > div { width: 20em !important; height: 20em !important; }</style>')
-            ui.joystick(
-                color='blue',
-                size=50,
-                on_move=lambda e: MinimalPublisher.update(e.y, e.x),
-                on_end=lambda _: MinimalPublisher.update(0.0, 0.0),
-            ).classes('my-joystick')
-
-        with ui.card():
-            ui.markdown('### Status')
-            
-            ui.label('linear speed')
-            ui.label().bind_text_from(MinimalPublisher, 'linear', backward=lambda value: f'{value:.3f}')
-            ui.label('angular speed')
-            ui.label().bind_text_from(MinimalPublisher, 'angular', backward=lambda value: f'{value:.3f}')
-
-def main() -> None:
-    pass  # NOTE: This is originally used as the ROS entry point, but we give the control of the node to NiceGUI.
-
-app.on_startup(lambda: threading.Thread(target=ros_main).start())
-run.APP_IMPORT_STRING = f'{__name__}:app'
-ui.run(port=8000, uvicorn_reload_dirs=str(Path(__file__).parent.resolve()))

+ 0 - 23
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/package.xml

@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
-<package format="3">
-  <name>nicegui_ros2</name>
-  <version>1.0.0</version>
-  <description>This is a basic example of Nicegui in a ROS2 node based on the minimal publisher example by ROS2</description>
-  <maintainer email="jens.ogorek@gmail.com">jens</maintainer>
-  <license>TODO: License declaration</license>
-  
-  <depend> rclpy </depend>
-  <depend> std_msgs </depend> 
-  <depend> geometry_msgs </depend>
-  <depend> nicegui </depend>
-  
-  <test_depend>ament_copyright</test_depend>
-  <test_depend>ament_flake8</test_depend>
-  <test_depend>ament_pep257</test_depend>
-  <test_depend>python3-pytest</test_depend>
-
-  <export>
-    <build_type>ament_python</build_type>
-  </export>
-</package>

+ 0 - 0
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/resource/nicegui_ros2


+ 0 - 4
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/setup.cfg

@@ -1,4 +0,0 @@
-[develop]
-script_dir=$base/lib/nicegui_ros2
-[install]
-install_scripts=$base/lib/nicegui_ros2

+ 0 - 28
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/setup.py

@@ -1,28 +0,0 @@
-from setuptools import setup
-
-package_name = 'nicegui_ros2'
-
-setup(
-    name=package_name,
-    version='1.0.0',
-    packages=[package_name],
-    data_files=[
-        ('share/ament_index/resource_index/packages',
-            ['resource/' + package_name]),
-        ('share/' + package_name, ['package.xml']),
-    ],
-    install_requires=['setuptools'],
-    zip_safe=True,
-    maintainer='jens',
-    maintainer_email='jens.ogorek@gmail.com',
-    description='This is a basic example of Nicegui in a ROS2 node based on the minimal publisher example by ROS2',
-    license='TODO: License declaration',
-    tests_require=['pytest'],
-    entry_points={
-        'console_scripts': [
-            'basic_nicegui = nicegui_ros2.basic_nicegui:main',
-            'joystick_nicegui = nicegui_ros2.joystick_nicegui:main',
-        ],
-
-    },
-)

+ 0 - 25
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/test/test_copyright.py

@@ -1,25 +0,0 @@
-# Copyright 2015 Open Source Robotics Foundation, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from ament_copyright.main import main
-import pytest
-
-
-# Remove the `skip` decorator once the source file(s) have a copyright header
-@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
-@pytest.mark.copyright
-@pytest.mark.linter
-def test_copyright():
-    rc = main(argv=['.', 'test'])
-    assert rc == 0, 'Found errors'

+ 0 - 25
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/test/test_flake8.py

@@ -1,25 +0,0 @@
-# Copyright 2017 Open Source Robotics Foundation, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from ament_flake8.main import main_with_errors
-import pytest
-
-
-@pytest.mark.flake8
-@pytest.mark.linter
-def test_flake8():
-    rc, errors = main_with_errors(argv=[])
-    assert rc == 0, \
-        'Found %d code style errors / warnings:\n' % len(errors) + \
-        '\n'.join(errors)

+ 0 - 23
examples/nicegui_ros2/ros2_ws/src/nicegui_ros2/test/test_pep257.py

@@ -1,23 +0,0 @@
-# Copyright 2015 Open Source Robotics Foundation, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from ament_pep257.main import main
-import pytest
-
-
-@pytest.mark.linter
-@pytest.mark.pep257
-def test_pep257():
-    rc = main(argv=['.', 'test'])
-    assert rc == 0, 'Found code style errors / warnings'