Skip to content

Commit

Permalink
Merge pull request #358 from JeremyZoss/2021.10/day1_updates
Browse files Browse the repository at this point in the history
day1 updates for clarity and consistency
  • Loading branch information
JeremyZoss committed Oct 4, 2021
2 parents fa74e33 + 12d8461 commit c4474e0
Show file tree
Hide file tree
Showing 31 changed files with 201 additions and 154 deletions.
3 changes: 2 additions & 1 deletion .check_training_config.bash
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function check_debs() {
check_deb ros-$ROS_RELEASE-desktop
check_deb ros-$ROS_RELEASE-perception
check_deb ros-$ROS_RELEASE-moveit
disable_deb ros-$ROS_RELEASE-industrial-core
check_deb ros-$ROS_RELEASE-industrial-core
disable_deb ros-$ROS_RELEASE-openni-launch
disable_deb ros-$ROS_RELEASE-openni-camera
disable_deb ros-$ROS_RELEASE-openni2-launch
Expand All @@ -97,6 +97,7 @@ function check_debs() {
check_deb python3-colcon-core
check_deb python3-colcon-ros
check_deb ros-$ROS2_RELEASE-desktop
check_deb ros-$ROS2_RELEASE-moveit
}

function check_bashrc() {
Expand Down
7 changes: 2 additions & 5 deletions exercises/1.3/ros2/src/myworkcell_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ find_package(rclcpp REQUIRED)
add_executable(vision_node src/vision_node.cpp)
ament_target_dependencies(vision_node rclcpp)

# Mark executables and/or libraries for installation
# Mark executables for installation
install(TARGETS vision_node
ARCHIVE DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib/${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion exercises/1.3/ros2/src/myworkcell_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>myworkcell_core</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>core scan-n-plan application node</description>
<maintainer email="me@rosindustrial.com">ROS-Industrial</maintainer>
<license>TODO: License declaration</license>

Expand Down
3 changes: 3 additions & 0 deletions exercises/1.3/ros2/src/myworkcell_core/src/vision_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
** Simple ROS Node
**/
#include <rclcpp/rclcpp.hpp>

int main(int argc, char* argv[])
Expand Down
7 changes: 2 additions & 5 deletions exercises/1.4/ros2/src/myworkcell_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ find_package(fake_ar_publisher REQUIRED)
add_executable(vision_node src/vision_node.cpp)
ament_target_dependencies(vision_node rclcpp fake_ar_publisher)

# Mark executables and/or libraries for installation
# Mark executables for installation
install(TARGETS vision_node
ARCHIVE DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib/${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion exercises/1.4/ros2/src/myworkcell_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>myworkcell_core</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>core scan-n-plan application node</description>
<maintainer email="me@rosindustrial.com">ROS-Industrial</maintainer>
<license>TODO: License declaration</license>

Expand Down
3 changes: 3 additions & 0 deletions exercises/1.4/ros2/src/myworkcell_core/src/vision_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
** Simple ROS Node
**/
#include <rclcpp/rclcpp.hpp>
#include <fake_ar_publisher/msg/ar_marker.hpp>

Expand Down
7 changes: 2 additions & 5 deletions exercises/2.0/ros2/src/myworkcell_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ add_executable(myworkcell_node src/myworkcell_node.cpp)
ament_target_dependencies(myworkcell_node rclcpp)
rosidl_target_interfaces(myworkcell_node ${PROJECT_NAME} "rosidl_typesupport_cpp")

# Mark executables and/or libraries for installation
# Mark executables for installation
install(TARGETS vision_node myworkcell_node
ARCHIVE DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib/${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion exercises/2.0/ros2/src/myworkcell_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>myworkcell_core</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>core scan-n-plan application node</description>
<maintainer email="me@rosindustrial.com">ROS-Industrial</maintainer>
<license>TODO: License declaration</license>
<member_of_group>rosidl_interface_packages</member_of_group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ScanNPlan : public rclcpp::Node
return;
}

RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
response->pose.position.x,
response->pose.position.y,
response->pose.position.z);
Expand Down
5 changes: 4 additions & 1 deletion exercises/2.0/ros2/src/myworkcell_core/src/vision_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
** Simple ROS Node
**/
#include <rclcpp/rclcpp.hpp>
#include <fake_ar_publisher/msg/ar_marker.hpp>
#include <myworkcell_core/srv/localize_part.hpp>
Expand Down Expand Up @@ -29,7 +32,7 @@ class Localizer : public rclcpp::Node
}

void localizePart(myworkcell_core::srv::LocalizePart::Request::SharedPtr req,
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
{
// Read last message
fake_ar_publisher::msg::ARMarker::SharedPtr p = last_msg_;
Expand Down
7 changes: 2 additions & 5 deletions exercises/2.2/ros2/src/myworkcell_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ add_executable(myworkcell_node src/myworkcell_node.cpp)
ament_target_dependencies(myworkcell_node rclcpp)
rosidl_target_interfaces(myworkcell_node ${PROJECT_NAME} "rosidl_typesupport_cpp")

# Mark executables and/or libraries for installation
# Mark executables for installation
install(TARGETS vision_node myworkcell_node
ARCHIVE DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib/${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion exercises/2.2/ros2/src/myworkcell_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>myworkcell_core</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>core scan-n-plan application node</description>
<maintainer email="me@rosindustrial.com">ROS-Industrial</maintainer>
<license>TODO: License declaration</license>
<member_of_group>rosidl_interface_packages</member_of_group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ScanNPlan : public rclcpp::Node
return;
}

RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
response->pose.position.x,
response->pose.position.y,
response->pose.position.z);
Expand Down
5 changes: 4 additions & 1 deletion exercises/2.2/ros2/src/myworkcell_core/src/vision_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
** Simple ROS Node
**/
#include <rclcpp/rclcpp.hpp>
#include <fake_ar_publisher/msg/ar_marker.hpp>
#include <myworkcell_core/srv/localize_part.hpp>
Expand Down Expand Up @@ -29,7 +32,7 @@ class Localizer : public rclcpp::Node
}

void localizePart(myworkcell_core::srv::LocalizePart::Request::SharedPtr req,
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
{
// Read last message
fake_ar_publisher::msg::ARMarker::SharedPtr p = last_msg_;
Expand Down
7 changes: 2 additions & 5 deletions exercises/2.3/ros2/src/myworkcell_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ add_executable(myworkcell_node src/myworkcell_node.cpp)
ament_target_dependencies(myworkcell_node rclcpp)
rosidl_target_interfaces(myworkcell_node ${PROJECT_NAME} "rosidl_typesupport_cpp")

# Mark executables and/or libraries for installation
# Mark executables for installation
install(TARGETS vision_node myworkcell_node
ARCHIVE DESTINATION lib/${PROJECT_NAME}
LIBRARY DESTINATION lib/${PROJECT_NAME}
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion exercises/2.3/ros2/src/myworkcell_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>myworkcell_core</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<description>core scan-n-plan application node</description>
<maintainer email="me@rosindustrial.com">ROS-Industrial</maintainer>
<license>TODO: License declaration</license>
<member_of_group>rosidl_interface_packages</member_of_group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ScanNPlan : public rclcpp::Node
return;
}

RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
RCLCPP_INFO(this->get_logger(), "Part Localized: x: %f, y: %f, z: %f",
response->pose.position.x,
response->pose.position.y,
response->pose.position.z);
Expand All @@ -60,8 +60,7 @@ int main(int argc, char **argv)
// Create the ScanNPlan node
auto app = std::make_shared<ScanNPlan>();

std::string base_frame;
app->get_parameter("base_frame", base_frame);
std::string base_frame = app->get_parameter("base_frame").as_string();

//Wait for the vision node to receive data
rclcpp::sleep_for(std::chrono::seconds(2));
Expand Down
5 changes: 4 additions & 1 deletion exercises/2.3/ros2/src/myworkcell_core/src/vision_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
** Simple ROS Node
**/
#include <rclcpp/rclcpp.hpp>
#include <fake_ar_publisher/msg/ar_marker.hpp>
#include <myworkcell_core/srv/localize_part.hpp>
Expand Down Expand Up @@ -29,7 +32,7 @@ class Localizer : public rclcpp::Node
}

void localizePart(myworkcell_core::srv::LocalizePart::Request::SharedPtr req,
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
myworkcell_core::srv::LocalizePart::Response::SharedPtr res)
{
// Read last message
fake_ar_publisher::msg::ARMarker::SharedPtr p = last_msg_;
Expand Down
8 changes: 4 additions & 4 deletions gh_pages/_downloads/ros-industrial-training-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ cd $HOME

# ROS1 packages source
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

# ROS2 packages source
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

sudo apt update -y

Expand All @@ -27,7 +27,7 @@ sudo apt install -y ros-noetic-industrial-core
sudo apt install -y pcl-tools

# ROS2 install
sudo apt install -y ros-foxy-desktop
sudo apt install -y ros-foxy-desktop ros-foxy-moveit
sudo apt install -y python3-colcon-common-extensions python3-argcomplete

# rosdep setup
Expand Down
Binary file not shown.
Binary file not shown.
21 changes: 15 additions & 6 deletions gh_pages/_source/session1/ros2/0-ROS-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ In order to start programming in ROS, you should know how to install ROS on a ne
We believe we have a good installation of ROS but let's test it to make sure.

## Scan-N-Plan Application: Guidance
### Setup ~/.bashrc
### Check Environment
1. If you are ever having problems finding or using your ROS packages make sure that you have your environment properly setup. A good way to check is to ensure that environment variables that ROS sets are present:

```
printenv | grep ROS
printenv | grep AMENT
env | grep ROS
env | grep AMENT
```

1. If they are not then you might need to 'source' some setup.*sh files.
Expand All @@ -29,10 +29,19 @@ We believe we have a good installation of ROS but let's test it to make sure.
source /opt/ros/foxy/setup.bash
```

1. In a "bare" ROS install, you will need to run this command on every new shell you open to have access to the ROS commands. One of the setup steps in a _typical_ ROS install is to add that command to the end of your `~/.bashrc` file, which is run automatically in every new terminal window. Check that your `.bashrc` file has already been configured to source the ROS-foxy `setup.bash` script:
1. Now repeat the check from above and verify that the environment variables are now present.

1. This process allows you to install several ROS distributions (even ROS1 and ROS2) side-by-side on the same computer and switch between them by sourcing the distribution-specific `setup.bash` file. Your training PC also has a ROS1 "noetic" distribution installed. Try activating that distribution in the same terminal window you used above and observe how the environment variables change.

```
tail ~/.bashrc
source /opt/ros/noetic/setup.bash
env | grep ROS
```

This process allows you to install several ROS distributions (even ROS1 and ROS2) on the same computer and switch between them by sourcing the distribution-specific `setup.bash` file.
1. If you switch back to the "foxy" ROS2 distribution, you'll notice that your environment is stil polluted with some variables from the ROS1 "noetic" distribution. To prevent confusion, it can be helpful to always start with a fresh terminal window rather than switching between distributions in the same terminal window.

In a "bare" ROS install, you will need to run the "source" command on **every** new shell you open to have access to the ROS commands. If your project only uses a single distribution, it can be helpful to configure our `~/.bashrc` file to automatically source this setup file for each new terminal window. See [here](https://docs.ros.org/en/foxy/Tutorials/Configuring-ROS2-Environment.html#add-sourcing-to-your-shell-startup-script) for details. Since this class uses content in both ROS1 and ROS2, we have not configured this auto-sourcing behavior for your training PC.

1. Open a new terminal window and source the ROS2 "foxy" distribution. Experiment with terminal windows, sourcing, and checking your environment until you are comfortable with this concept.

**Remember to source the appropriate `setup` script in every new terminal window you open. Forgetting this step is a common error among new ROS users.**
21 changes: 14 additions & 7 deletions gh_pages/_source/session1/ros2/1-Create-ROS-Workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ We have a good installation of ROS, and we need to take the first step to settin

### Create a Workspace

1. Close any open terminal windows. Open a new terminal and source the "foxy" distribution.

```
source /opt/ros/foxy/setup.bash
```

1. Create the root workspace directory. Note that the required structure is a top-level directory and a `src/` directory one level down. The directory name is a completely free choice. We will use `ros2_ws` throughout these tutorials.

```
cd ~/
mkdir --parents ros2_ws/src
cd ros2_ws
ls
```

1. Build the workspace from the workspace root-directory (`ros2_ws`).
Expand All @@ -33,8 +40,10 @@ We have a good installation of ROS, and we need to take the first step to settin
```

* _See that the `ros2_ws` directory now contains additional directories (build, install, log)._
* `colcon build` must always be run from the **root** of your workspace directory.
* Don't run `colcon build` from a terminal where you've also sourced this workspace's setup file. Use a dedicated terminal for building.

1. These new directories can be safely deleted at any time. Note that colcon never changes any files in the `src` directory. Re-run `colcon build` to re-create the build/install/log directories.
1. These new directories can be safely deleted at any time. This is sometimes used to resolve unusual build errors by "starting with a clean slate". Note that colcon never changes any files in the `src` directory. Re-run `colcon build` to re-create the build/install/log directories.

```
rm -r build/ install/ log/
Expand All @@ -43,15 +52,13 @@ We have a good installation of ROS, and we need to take the first step to settin
ls
```

1. Make the workspace visible to ROS. Source the setup file in the install directory.
1. Make the contents of this workspace visible to ROS. Source the setup file in the install directory.

```
source install/setup.bash
source ~/ros2_ws/install/setup.bash
```

* _This file MUST be sourced for every new terminal._
* To save typing, add this to your `~/.bashrc` file, so it is automatically sourced for each new terminal:
* This file will automatically include the ROS environment that was active when you first built this workspace. Make sure you have sourced the correct ROS distribution before building a new workspace for the first time!


1. `gedit ~/.bashrc`
1. add to the end: `source ~/ros2_ws/install/setup.bash`
1. save and close the editor

0 comments on commit c4474e0

Please sign in to comment.