Skip to content

Commit

Permalink
move ros2_terminal_commands out of intro_to_ros and add cd ~/auvc_ws …
Browse files Browse the repository at this point in the history
…&& as a requirement in the colcon build commands (#9)

* Delete docs/2-module/1_software_stack.mdx

* Delete docs/2-module/2_data_collection.mdx

* Delete docs/2-module/3_remote_operations.mdx

* Delete docs/2-module/4_open_loop_control.mdx

* Delete docs/2-module/5_sil_sim.mdx

* Create 20_ros2_terminal_commands.mdx

* Update 20_ros2_terminal_commands.mdx

* Update 20_ros2_terminal_commands.mdx

* Update 20_ros2_terminal_commands.mdx

* Update 10_intro_to_ros.mdx
  • Loading branch information
marinarasauced authored Jul 18, 2024
1 parent ca264ab commit 5d32ab0
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 145 deletions.
85 changes: 0 additions & 85 deletions docs/2-module/10_intro_to_ros.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -380,91 +380,6 @@ Now that you have confirmed each node works independently, run an instance of ea
Review with a TA or instructor to check-off this section.
:::

## ROS2 Terminal Commands

This section breaks down useful terminal commands for debugging and testing in the ROS2 environment.

:::warning Warning
You do not need to run commands in this section in the terminal at this time.
:::

1. Create a new package (must be executed a workspace's `src` directory; e.g., `~/auvc_ws/src`)

```zsh
ros2 pkg create --build-type ament_python your_package_name
```

2. Build all packages in a workspace (must be executed in the workspace directory; e.g., `~/auvc_ws`):

```zsh
colcon build
```

3. Build a specific package within a workspace (must be executed in the workspace directory; e.g., `~/auvc_ws`):

```zsh
colcon build --packages-select your_package_name
```

4. Create symbolic links while building (if you modify any currently existing files in the package, you won't need to recompile):

```zsh
colcon build --packages-select your_package_name --symlink-install
```

5. Run an individual node:
```zsh
ros2 run your_package_name your_executable_name
```

6. List all active nodes:

```zsh
ros2 node list
```

7. List all named topics:

```zsh
ros2 topic list
```

8. Check the message type of a topic:

```zsh
ros2 topic type /your/topic
```

9. Echo all messages on a specific topic to the current terminal:

```zsh
ros2 topic echo /your/topic
```

10. Manually publish a message on a topic `N` times:

```zsh
ros2 topic echo -N /your_topic std_msgs/String '{data: "hello world"}'
```

11. Check the frequency of messages on a topic:

```zsh
ros2 topic hz /your/topic
```

12. Source the ROS2 installation manually:

```zsh
source /opt/ros/jazzy/setup.zsh
```

13. Source a workspace manually:

```zsh
source ~/auvc_ws/install/setup.zsh
```

## Problem Set

### Problem Set Setup
Expand Down
3 changes: 0 additions & 3 deletions docs/2-module/1_software_stack.mdx

This file was deleted.

102 changes: 102 additions & 0 deletions docs/2-module/20_ros2_terminal_commands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
slidebar_position: 2
---

# ROS2 Terminal Commands

## Creating ROS2 workspaces

Workspaces in ROS2 are locations where user-written code is stored and compiled. Workspaces can be located at any path; however, it is recommended to create them in the home directory. The below command navigates to home, creates a directory called `auvc_ws/`, navigates to `auvc_ws/src/`, then initializes the workspace using `colcon build`.

```zsh
cd && mkdir auvc_ws && cd auvc_ws && mkdir src && colcon build
```

## Creating ROS2 packages

To create a new ROS2 package, you must have a ROS2 workspace. Packages MUST be located within the workspace's `src` directory; e.g., `~/auvc_ws/src/my_package`.

```zsh
cd ~/auvc_ws/src && ros2 pkg create --build-type ament_cmake my_package_name
```

## Compiling ROS2 packages

ROS2 utilizes a compiling tool called `colcon build`. When you use this tool, you MUST be in the workspace directory; e.g., `auvc_ws`. Check your current using `pwd` (print working directory).

```zsh
pwd
```

If your path does not look like `/home/YOUR_USERNAME/auvc_ws, DO NOT use `colcon build`. Instead, navigate to the workspace AND THEN run `colcon build`.

```zsh
cd ~/auvc_ws && colcon build
```

### Additional colcon build arguments

You can specify additional arguments while using `colcon build` to increase compiling speed.

Adding `--packages-select MY_PACKAGE` allows you to recompile one specific package.

```zsh
cd ~/auvc_ws && colcon build --packages-select YOUR_PACKAGE
```

Adding `--symlink-install` creates a symbolic link between currently existing files in `~/auvc_ws/src/YOUR_PACKAGE` and `~/auvc_ws/install`. If you use this argument, currently existing files AND ONLY those files will not need to be recompiled. If you do add or remove files, recompile.

```zsh
cd ~/auvc_ws && colcon build --symlink-install --packages-select YOUR_PACKAGE
```

### Sourcing the workspace

After you compile a package, if you added new executables, you must re-source the workspace.

```zsh
source ~/auvc_ws/install/setup.zsh
```

## Node Commands

### List all active nodes

```zsh
ros2 node list
```

## Topic Commands

### List all named topics

```zsh
ros2 topic list
```

### Check the message type of a topic

```zsh
ros2 topic type /your/topic
```

### View message data in the terminal

```zsh
ros2 topic echo /your/topic
```

### Manually publish data to a topic

```zsh
ros2 topic echo -1 /your/topic std_msgs/String '{data: "hello world"}'
```

## Package Commands

### Check what executables are in a node

```zsh
ros2 pkg interface show /your_package
```

7 changes: 0 additions & 7 deletions docs/2-module/2_data_collection.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions docs/2-module/3_remote_operations.mdx

This file was deleted.

36 changes: 0 additions & 36 deletions docs/2-module/4_open_loop_control.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions docs/2-module/5_sil_sim.mdx

This file was deleted.

0 comments on commit 5d32ab0

Please sign in to comment.