diff --git a/code-snippets/ros2 node templete/.vscode/c_cpp_properties.json b/code-snippets/ros2 node templete/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..6c29a86
--- /dev/null
+++ b/code-snippets/ros2 node templete/.vscode/c_cpp_properties.json
@@ -0,0 +1,17 @@
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "includePath": [
+ "${workspaceFolder}/**",
+ "/opt/ros/foxy/include"
+ ],
+ "defines": [],
+ "compilerPath": "/usr/bin/gcc",
+ "cStandard": "c11",
+ "cppStandard": "gnu++14",
+ "intelliSenseMode": "clang-x64"
+ }
+ ],
+ "version": 4
+}
\ No newline at end of file
diff --git a/code-snippets/ros2 node templete/.vscode/settings.json b/code-snippets/ros2 node templete/.vscode/settings.json
new file mode 100644
index 0000000..430fb14
--- /dev/null
+++ b/code-snippets/ros2 node templete/.vscode/settings.json
@@ -0,0 +1,69 @@
+{
+ "files.associations": {
+ "cctype": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "csignal": "cpp",
+ "cstdarg": "cpp",
+ "cstddef": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cstring": "cpp",
+ "ctime": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "array": "cpp",
+ "atomic": "cpp",
+ "strstream": "cpp",
+ "bit": "cpp",
+ "*.tcc": "cpp",
+ "bitset": "cpp",
+ "chrono": "cpp",
+ "complex": "cpp",
+ "condition_variable": "cpp",
+ "cstdint": "cpp",
+ "deque": "cpp",
+ "list": "cpp",
+ "map": "cpp",
+ "set": "cpp",
+ "unordered_map": "cpp",
+ "vector": "cpp",
+ "exception": "cpp",
+ "algorithm": "cpp",
+ "functional": "cpp",
+ "iterator": "cpp",
+ "memory": "cpp",
+ "memory_resource": "cpp",
+ "numeric": "cpp",
+ "optional": "cpp",
+ "random": "cpp",
+ "ratio": "cpp",
+ "string": "cpp",
+ "string_view": "cpp",
+ "system_error": "cpp",
+ "tuple": "cpp",
+ "type_traits": "cpp",
+ "utility": "cpp",
+ "fstream": "cpp",
+ "future": "cpp",
+ "initializer_list": "cpp",
+ "iomanip": "cpp",
+ "iosfwd": "cpp",
+ "iostream": "cpp",
+ "istream": "cpp",
+ "limits": "cpp",
+ "mutex": "cpp",
+ "new": "cpp",
+ "ostream": "cpp",
+ "shared_mutex": "cpp",
+ "sstream": "cpp",
+ "stdexcept": "cpp",
+ "streambuf": "cpp",
+ "thread": "cpp",
+ "cfenv": "cpp",
+ "cinttypes": "cpp",
+ "typeindex": "cpp",
+ "typeinfo": "cpp",
+ "variant": "cpp"
+ }
+}
\ No newline at end of file
diff --git a/code-snippets/ros2 node templete/my_cpp_pkg/CMakeLists.txt b/code-snippets/ros2 node templete/my_cpp_pkg/CMakeLists.txt
new file mode 100644
index 0000000..f7553dc
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_cpp_pkg/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.5)
+project(my_cpp_pkg)
+
+# Default to C++14
+if(NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 14)
+endif()
+
+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)
+find_package(rclcpp REQUIRED)
+
+add_executable(cpp_node src/my_first_node.cpp)
+ament_target_dependencies(cpp_node rclcpp)
+
+install(TARGETS
+ cpp_node
+ DESTINATION lib/${PROJECT_NAME}
+)
+
+ament_package()
diff --git a/code-snippets/ros2 node templete/my_cpp_pkg/package.xml b/code-snippets/ros2 node templete/my_cpp_pkg/package.xml
new file mode 100644
index 0000000..35ad04a
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_cpp_pkg/package.xml
@@ -0,0 +1,20 @@
+
+
+
+ my_cpp_pkg
+ 0.0.0
+ TODO: Package description
+ ed
+ TODO: License declaration
+
+ ament_cmake
+
+ rclcpp
+
+ ament_lint_auto
+ ament_lint_common
+
+
+ ament_cmake
+
+
diff --git a/code-snippets/ros2 node templete/my_cpp_pkg/src/my_first_node.cpp b/code-snippets/ros2 node templete/my_cpp_pkg/src/my_first_node.cpp
new file mode 100644
index 0000000..ebef0fa
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_cpp_pkg/src/my_first_node.cpp
@@ -0,0 +1,32 @@
+#include "rclcpp/rclcpp.hpp"
+
+class MyNode : public rclcpp::Node
+{
+public:
+ MyNode() : Node("cpp_test"), counter_(0)
+ {
+ RCLCPP_INFO(this->get_logger(), "Hello Cpp Node");
+
+ timer_ = this->create_wall_timer(std::chrono::seconds(1),
+ std::bind(&MyNode::timerCallback, this));
+ }
+
+private:
+ void timerCallback()
+ {
+ counter_++;
+ RCLCPP_INFO(this->get_logger(), "Hello %d", counter_);
+ }
+
+ rclcpp::TimerBase::SharedPtr timer_;
+ int counter_;
+};
+
+int main(int argc, char **argv)
+{
+ rclcpp::init(argc, argv);
+ auto node = std::make_shared();
+ rclcpp::spin(node);
+ rclcpp::shutdown();
+ return 0;
+}
\ No newline at end of file
diff --git a/code-snippets/ros2 node templete/my_cpp_pkg/src/template_cpp_node.cpp b/code-snippets/ros2 node templete/my_cpp_pkg/src/template_cpp_node.cpp
new file mode 100644
index 0000000..3d46a64
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_cpp_pkg/src/template_cpp_node.cpp
@@ -0,0 +1,20 @@
+#include "rclcpp/rclcpp.hpp"
+
+class MyCustomNode : public rclcpp::Node // MODIFY NAME
+{
+public:
+ MyCustomNode() : Node("node_name") // MODIFY NAME
+ {
+ }
+
+private:
+};
+
+int main(int argc, char **argv)
+{
+ rclcpp::init(argc, argv);
+ auto node = std::make_shared(); // MODIFY NAME
+ rclcpp::spin(node);
+ rclcpp::shutdown();
+ return 0;
+}
diff --git a/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/__init__.py b/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/my_first_node.py b/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/my_first_node.py
new file mode 100755
index 0000000..61b7d52
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/my_first_node.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import rclpy
+from rclpy.node import Node
+
+
+class MyNode(Node):
+
+ def __init__(self):
+ super().__init__("py_test")
+ self.counter_ = 0
+ self.get_logger().info("Hello ROS2")
+ self.create_timer(0.5, self.timer_callback)
+
+ def timer_callback(self):
+ self.counter_ += 1
+ self.get_logger().info("Hello " + str(self.counter_))
+
+
+def main(args=None):
+ rclpy.init(args=args)
+ node = MyNode()
+ rclpy.spin(node)
+ rclpy.shutdown()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/template_python_node.py b/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/template_python_node.py
new file mode 100644
index 0000000..0a70ab7
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/my_py_pkg/template_python_node.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+import rclpy
+from rclpy.node import Node
+
+
+class MyCustomNode(Node): # MODIFY NAME
+ def __init__(self):
+ super().__init__("node_name") # MODIFY NAME
+
+
+def main(args=None):
+ rclpy.init(args=args)
+ node = MyCustomNode() # MODIFY NAME
+ rclpy.spin(node)
+ rclpy.shutdown()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/code-snippets/ros2 node templete/my_py_pkg/package.xml b/code-snippets/ros2 node templete/my_py_pkg/package.xml
new file mode 100644
index 0000000..f7476eb
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/package.xml
@@ -0,0 +1,20 @@
+
+
+
+ my_py_pkg
+ 0.0.0
+ TODO: Package description
+ ed
+ TODO: License declaration
+
+ rclpy
+
+ ament_copyright
+ ament_flake8
+ ament_pep257
+ python3-pytest
+
+
+ ament_python
+
+
diff --git a/code-snippets/ros2 node templete/my_py_pkg/resource/my_py_pkg b/code-snippets/ros2 node templete/my_py_pkg/resource/my_py_pkg
new file mode 100644
index 0000000..e69de29
diff --git a/code-snippets/ros2 node templete/my_py_pkg/setup.cfg b/code-snippets/ros2 node templete/my_py_pkg/setup.cfg
new file mode 100644
index 0000000..93e8d76
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/setup.cfg
@@ -0,0 +1,4 @@
+[develop]
+script-dir=$base/lib/my_py_pkg
+[install]
+install-scripts=$base/lib/my_py_pkg
diff --git a/code-snippets/ros2 node templete/my_py_pkg/setup.py b/code-snippets/ros2 node templete/my_py_pkg/setup.py
new file mode 100644
index 0000000..99d963a
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/setup.py
@@ -0,0 +1,26 @@
+from setuptools import setup
+
+package_name = 'my_py_pkg'
+
+setup(
+ name=package_name,
+ version='0.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='ed',
+ maintainer_email='ed@todo.todo',
+ description='TODO: Package description',
+ license='TODO: License declaration',
+ tests_require=['pytest'],
+ entry_points={
+ 'console_scripts': [
+ "py_node = my_py_pkg.my_first_node:main"
+ ],
+ },
+)
diff --git a/code-snippets/ros2 node templete/my_py_pkg/test/test_copyright.py b/code-snippets/ros2 node templete/my_py_pkg/test/test_copyright.py
new file mode 100644
index 0000000..cc8ff03
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/test/test_copyright.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_copyright.main import main
+import pytest
+
+
+@pytest.mark.copyright
+@pytest.mark.linter
+def test_copyright():
+ rc = main(argv=['.', 'test'])
+ assert rc == 0, 'Found errors'
diff --git a/code-snippets/ros2 node templete/my_py_pkg/test/test_flake8.py b/code-snippets/ros2 node templete/my_py_pkg/test/test_flake8.py
new file mode 100644
index 0000000..27ee107
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/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/code-snippets/ros2 node templete/my_py_pkg/test/test_pep257.py b/code-snippets/ros2 node templete/my_py_pkg/test/test_pep257.py
new file mode 100644
index 0000000..b234a38
--- /dev/null
+++ b/code-snippets/ros2 node templete/my_py_pkg/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/docs/General ROS 2/Building ROS2 packages.md b/docs/General ROS 2/Building ROS2 packages.md
index 03610b7..adcb4db 100755
--- a/docs/General ROS 2/Building ROS2 packages.md
+++ b/docs/General ROS 2/Building ROS2 packages.md
@@ -1,10 +1,22 @@
-# Setting up VSCode
+# Setup
+## Installing VSCode
first install vscode using snap
```bash
sudo snap install code --classic
```
then add the `ROS` extension from Microsoft.
+## Installing Colcon
+To install colcon first run the sudo apt install command.
+``` bash
+sudo apt install python3-colcon-common-extensions
+```
+
+then add the colcon autocomplete to the `.bashrc` file.
+``` bash
+echo 'source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash' >> ~/.bashrc
+```
+
# Setting up the ROS2 Package Workspace
first create the folder for the package usual it is called `packagename_ws`where `_ws` stands for then you enter the directory and create another directory called `src` then run the `colcon build` command.
@@ -13,12 +25,9 @@ colcon build
```
next go into the `install` folder and add the `setup.bash` source command to your `~/.bashrc`
```bash
-...
-source /home/username/package_ws/install/setup.bash
+echo "source /home/username/package_ws/install/setup.bash" >> ~/.bashrc
```
-
-
## Creating a Python Packages
#### Setting Up
Go to the workspace folder that was created in the last step and open the `src` folder. In this folder run this command.
@@ -88,6 +97,7 @@ then just like before run the `source ~/.bashrc` command to refresh everything a
## Creating a C++ Packages
Go to the workspace folder that was created in the last step and open the `src` folder. In this folder run this command.
```bash
-ros2 pkg create {package_name} --build-type ament_cmake
+ros2 pkg create {package_name} --build-type ament_cmake --dependencies rclcpp
```
+![Image title](img/ros2_nodes.png)
diff --git a/docs/General ROS 2/Colcon.md b/docs/General ROS 2/Colcon.md
new file mode 100755
index 0000000..7b6f188
--- /dev/null
+++ b/docs/General ROS 2/Colcon.md
@@ -0,0 +1,10 @@
+# Installing
+To install colcon first run the sudo apt install command.
+``` bash
+sudo apt install python3-colcon-common-extensions
+```
+
+then add the colcon autocomplete to the `.bashrc` file.
+``` bash
+echo 'source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash' >> ~/.bashrc
+```
\ No newline at end of file
diff --git a/docs/TurtleBot 4/SLAM and Navigation.md b/docs/TurtleBot 4/SLAM and Navigation.md
index 60fd370..7fe25b0 100755
--- a/docs/TurtleBot 4/SLAM and Navigation.md
+++ b/docs/TurtleBot 4/SLAM and Navigation.md
@@ -20,8 +20,7 @@ Once this command is running then you should be able to drive the robot like nor
### Launching the SLAM command
Here is the `slam.yaml` config file. You can change the resolution by changing the resolution parameter, by default it is 0.05 but i have had great success when running synchronous SLAM with values as low as 0.01.
-
-```yaml title="slam.yaml"
+```yaml
slam_toolbox:
ros__parameters:
@@ -101,13 +100,12 @@ ros2 launch turtlebot4_viz view_robot.launch.py
Once you are done creating the map make sure you save it.
```bash
-ros2 run nav2_map_server map_saver_cli -f "map_name"
+
```
#### Navigation
To launch the navigation program on the Turtlebot 4 run the following commands. One per terminal window making sure to execute them on the Remote PC.
-
```bash
# Terminal Window 1
ros2 launch turtlebot4_navigation localization.launch.py map:/path/to/map.yaml
@@ -119,4 +117,4 @@ ros2 launch turtlebot4_navigation nav2.launch.py
ros2 launch turtlebot4_viz view_robot.launch.py
```
-Use the `2D Pose Estimate` to select the spot on the map were the robot is at when the Navigation is launched. Then use the `Nav2 Goal` button to select where the robot should navigate to.
+Use the `2D Pose Estimate` to select the spot on the map were the robot is at when the Navigation is launched. Then use the `Nav2 Goal` button to select where the robot should navigate to.
\ No newline at end of file
diff --git a/docs/img/ros2_nodes.png b/docs/img/ros2_nodes.png
new file mode 100755
index 0000000..eb78c89
Binary files /dev/null and b/docs/img/ros2_nodes.png differ
diff --git a/mkdocs.yml b/mkdocs.yml
index 7e6b848..ab825e0 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -39,7 +39,7 @@ extra:
link: https://gitea.locker98.com
copyright: |
- © 2023 locker98
+ © 2024 locker98
markdown_extensions:
- pymdownx.highlight:
@@ -56,4 +56,4 @@ markdown_extensions:
- attr_list
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
- emoji_generator: !!python/name:materialx.emoji.to_svg
\ No newline at end of file
+ emoji_generator: !!python/name:materialx.emoji.to_svg