From a391de527de1d5e824cc18ad42b2cc93bbec94b5 Mon Sep 17 00:00:00 2001 From: locker98 Date: Wed, 18 Dec 2024 19:29:23 -0500 Subject: [PATCH] added files --- .vscode/c_cpp_properties.json | 24 ++ .vscode/settings.json | 16 + README.md | 2 + locker98_tools/locker98_tools/__init__.py | 0 locker98_tools/locker98_tools/joy_teleop.py | 61 ++++ locker98_tools/package.xml | 23 ++ locker98_tools/resource/locker98_tools | 0 locker98_tools/setup.cfg | 4 + locker98_tools/setup.py | 26 ++ locker98_tools/test/test_copyright.py | 25 ++ locker98_tools/test/test_flake8.py | 25 ++ locker98_tools/test/test_pep257.py | 23 ++ locker98_tools_bringup/CMakeLists.txt | 26 ++ locker98_tools_bringup/launch/nav2.launch.xml | 1 + locker98_tools_bringup/launch/slam.launch.xml | 1 + locker98_tools_bringup/package.xml | 18 ++ locker98_tools_bringup/rviz/nav2_config.rviz | 301 ++++++++++++++++++ 17 files changed, 576 insertions(+) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 locker98_tools/locker98_tools/__init__.py create mode 100755 locker98_tools/locker98_tools/joy_teleop.py create mode 100644 locker98_tools/package.xml create mode 100644 locker98_tools/resource/locker98_tools create mode 100644 locker98_tools/setup.cfg create mode 100644 locker98_tools/setup.py create mode 100644 locker98_tools/test/test_copyright.py create mode 100644 locker98_tools/test/test_flake8.py create mode 100644 locker98_tools/test/test_pep257.py create mode 100644 locker98_tools_bringup/CMakeLists.txt create mode 100644 locker98_tools_bringup/launch/nav2.launch.xml create mode 100644 locker98_tools_bringup/launch/slam.launch.xml create mode 100644 locker98_tools_bringup/package.xml create mode 100644 locker98_tools_bringup/rviz/nav2_config.rviz diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..7aa1ac8 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,24 @@ +{ + "configurations": [ + { + "browse": { + "databaseFilename": "${default}", + "limitSymbolsToIncludedHeaders": false + }, + "includePath": [ + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/my_robot_interfaces/include/**", + "/home/ros-laptop1/Desktop/turtlebot3_ws/install/turtlebot3_gazebo/include/**", + "/home/ros-laptop1/Desktop/turtlebot3_ws/install/turtlebot3_fake_node/include/**", + "/opt/ros/humble/include/**", + "/home/ros-laptop1/Desktop/locker98_tools_ws/src/locker98_tools_bringup/include/**", + "/usr/include/**" + ], + "name": "ROS", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu11", + "cppStandard": "c++14" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..22ff4a0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "python.autoComplete.extraPaths": [ + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/turtlesim_catch_them_all/lib/python3.10/site-packages", + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/my_py_pkg/lib/python3.10/site-packages", + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/my_robot_interfaces/local/lib/python3.10/dist-packages", + "/opt/ros/humble/lib/python3.10/site-packages", + "/opt/ros/humble/local/lib/python3.10/dist-packages" + ], + "python.analysis.extraPaths": [ + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/turtlesim_catch_them_all/lib/python3.10/site-packages", + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/my_py_pkg/lib/python3.10/site-packages", + "/home/ros-laptop1/Desktop/turtlebotrhodes_ws/install/my_robot_interfaces/local/lib/python3.10/dist-packages", + "/opt/ros/humble/lib/python3.10/site-packages", + "/opt/ros/humble/local/lib/python3.10/dist-packages" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f704ad1 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Locker98_Tools +This ROS2 work space is a collection of tools and ros2 scripts that I find useful on a regular basis. diff --git a/locker98_tools/locker98_tools/__init__.py b/locker98_tools/locker98_tools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/locker98_tools/locker98_tools/joy_teleop.py b/locker98_tools/locker98_tools/joy_teleop.py new file mode 100755 index 0000000..7d0e038 --- /dev/null +++ b/locker98_tools/locker98_tools/joy_teleop.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +import rclpy +from rclpy.node import Node +import pygame +import time +from geometry_msgs.msg import Twist + + + + +class JoyTeleopNode(Node): + def __init__(self, joystick): + super().__init__("joy_teleop") + self.joystick = joystick + self.publisher_ = self.create_publisher(Twist, "/cmd_vel", 10) + self.timer_ = self.create_timer(0.1, self.publish_news) + self.get_logger().info("Starting the robot news station") + + def publish_news(self): + r, move = self.get_joystick_right_stick() + + msg = Twist() + msg.linear.x = move*2 + msg.angular.z = r*2 + self.publisher_.publish(msg) + + def get_joystick_right_stick(self): + # Pump the event queue to prevent freezing + pygame.event.pump() + # Get right joystick axis values + right_x = round(self.joystick.get_axis(3), 2)/3 # Adjust index if not correct + right_y = round(self.joystick.get_axis(4), 2)/4 # Adjust index if not correct + if right_x < 0.02 and right_x > -0.02: + right_x = 0.0 + if right_y < 0.02 and right_y > -0.02: + right_y = 0.0 + return right_x, -right_y + + + +def main (args=None): + # Initialize pygame + pygame.init() + pygame.joystick.init() + # Find Controller + if pygame.joystick.get_count() == 0: + print("No joystick detected.") + exit(0) + + # Open the first joystick + joystick = pygame.joystick.Joystick(0) + joystick.init() + + # Start ROS 2 Node + rclpy.init(args=args) + node = JoyTeleopNode(joystick) + rclpy.spin(node) + rclpy.shutdown() + +if __name__ == '__main__': + main() diff --git a/locker98_tools/package.xml b/locker98_tools/package.xml new file mode 100644 index 0000000..8799ba5 --- /dev/null +++ b/locker98_tools/package.xml @@ -0,0 +1,23 @@ + + + + locker98_tools + 0.0.1 + This is a collection of tools that I find useful on a regular basis. + locker98 + GNU 3.0 + + rclpy + geometry_msgs + time + pygame + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/locker98_tools/resource/locker98_tools b/locker98_tools/resource/locker98_tools new file mode 100644 index 0000000..e69de29 diff --git a/locker98_tools/setup.cfg b/locker98_tools/setup.cfg new file mode 100644 index 0000000..c3f2400 --- /dev/null +++ b/locker98_tools/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/locker98_tools +[install] +install_scripts=$base/lib/locker98_tools diff --git a/locker98_tools/setup.py b/locker98_tools/setup.py new file mode 100644 index 0000000..2076b8a --- /dev/null +++ b/locker98_tools/setup.py @@ -0,0 +1,26 @@ +from setuptools import find_packages, setup + +package_name = 'locker98_tools' + +setup( + name=package_name, + version='0.0.1', + packages=find_packages(exclude=['test']), + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='locker98', + maintainer_email='coolemail45@proton.me', + description='This is a collection of tools that I find useful on a regular basis.', + license='GNU 3.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + "joy_teleop = locker98_tools.joy_teleop:main" + ], + }, +) diff --git a/locker98_tools/test/test_copyright.py b/locker98_tools/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/locker98_tools/test/test_copyright.py @@ -0,0 +1,25 @@ +# 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' diff --git a/locker98_tools/test/test_flake8.py b/locker98_tools/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/locker98_tools/test/test_flake8.py @@ -0,0 +1,25 @@ +# 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) diff --git a/locker98_tools/test/test_pep257.py b/locker98_tools/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/locker98_tools/test/test_pep257.py @@ -0,0 +1,23 @@ +# 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' diff --git a/locker98_tools_bringup/CMakeLists.txt b/locker98_tools_bringup/CMakeLists.txt new file mode 100644 index 0000000..9df360e --- /dev/null +++ b/locker98_tools_bringup/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.8) +project(locker98_tools_bringup) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/locker98_tools_bringup/launch/nav2.launch.xml b/locker98_tools_bringup/launch/nav2.launch.xml new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/locker98_tools_bringup/launch/nav2.launch.xml @@ -0,0 +1 @@ + diff --git a/locker98_tools_bringup/launch/slam.launch.xml b/locker98_tools_bringup/launch/slam.launch.xml new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/locker98_tools_bringup/launch/slam.launch.xml @@ -0,0 +1 @@ + diff --git a/locker98_tools_bringup/package.xml b/locker98_tools_bringup/package.xml new file mode 100644 index 0000000..e8a56f3 --- /dev/null +++ b/locker98_tools_bringup/package.xml @@ -0,0 +1,18 @@ + + + + locker98_tools_bringup + 0.0.1 + This is a collection of launch files that I find useful on a regular basis. + locker98 + GNU 3.0 + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/locker98_tools_bringup/rviz/nav2_config.rviz b/locker98_tools_bringup/rviz/nav2_config.rviz new file mode 100644 index 0000000..9f73b51 --- /dev/null +++ b/locker98_tools_bringup/rviz/nav2_config.rviz @@ -0,0 +1,301 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 87 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /Map1 + - /Map1/Topic1 + - /LaserScan1 + - /Global cost map1 + - /Local Cost Map1 + Splitter Ratio: 0.5 + Tree Height: 637 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 0.699999988079071 + Class: rviz_default_plugins/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: + Depth: 5 + Durability Policy: Transient Local + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /map + Update Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /map_updates + Use Timestamp: false + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz_default_plugins/LaserScan + Color: 255; 255; 255 + Color Transformer: Intensity + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Max Intensity: 0 + Min Color: 0; 0; 0 + Min Intensity: 0 + Name: LaserScan + Position Transformer: XYZ + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /scan + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + base_footprint: + Value: true + base_link: + Value: true + base_scan: + Value: true + camera_depth_frame: + Value: true + camera_depth_optical_frame: + Value: true + camera_link: + Value: true + camera_rgb_frame: + Value: true + camera_rgb_optical_frame: + Value: true + caster_back_left_link: + Value: true + caster_back_right_link: + Value: true + imu_link: + Value: true + map: + Value: true + odom: + Value: true + wheel_left_link: + Value: true + wheel_right_link: + Value: true + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: false + Tree: + map: + odom: + base_footprint: + base_link: + base_scan: + {} + camera_link: + camera_depth_frame: + camera_depth_optical_frame: + {} + camera_rgb_frame: + camera_rgb_optical_frame: + {} + caster_back_left_link: + {} + caster_back_right_link: + {} + imu_link: + {} + wheel_left_link: + {} + wheel_right_link: + {} + Update Interval: 0 + Value: true + - Alpha: 0.699999988079071 + Class: rviz_default_plugins/Map + Color Scheme: costmap + Draw Behind: false + Enabled: true + Name: Global cost map + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /global_costmap/costmap + Update Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /global_costmap/costmap_updates + Use Timestamp: false + Value: true + - Alpha: 0.699999988079071 + Class: rviz_default_plugins/Map + Color Scheme: costmap + Draw Behind: false + Enabled: true + Name: Local Cost Map + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /local_costmap/costmap + Update Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /local_costmap/costmap_updates + Use Timestamp: false + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: map + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 6.541196823120117 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: -0.873987078666687 + Y: 1.3103702068328857 + Z: -0.06853076070547104 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 1.421534776687622 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.7348731160163879 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1001 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd00000004000000000000016a00000323fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000007901000003fb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000004e00000323000000ff01000003fb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000011000000323fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000004e00000323000000d701000003fb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000004efc0100000002fb0000000800540069006d0065010000000000000780000002e701000003fb0000000800540069006d00650100000000000004500000000000000000000005040000032300000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1920 + X: 0 + Y: 0