- Open a new terminal and source the workspace
cd ~/ros2_helloworld_ws
source install/local_setup.bash
Create a new package
cd ~/ros2_ws/src
ros2 pkg create monitor_station --build-type ament_python --dependencies rclpy
code monitor_station/
Install extra dependencies
import random | |
CHOICES = ['R', 'P', 'S'] | |
# Ask user for input (rock, paper, or scissors) | |
user_input = input('Rock, paper or scissors (type R, P, or S): ') | |
# Check if user input is valid | |
if user_input not in CHOICES: | |
print('Invalid choice') |
Original setup guide: https://rebrand.ly/ros/install
NOTE: I recommend opening this guide up within the VirtualBox. Here's the short link for easy access: rebrand.ly/ros/quick-install
su
adduser <username> sudo
exit
# Usage: install-python <VERSION> | |
# Example: install-python 3.6.9 | |
function install_python() { | |
VERSION=$1 | |
sudo apt install gcc make zlib1g-dev | |
sudo apt install libssl-dev # needed for SSL support | |
sudo apt install libsqlite3-dev # needed for SQLite support | |
sudo apt-get install libbz2-dev # needed for BZ2 compression support | |
wget "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz" |
VERSION=$1 | |
sudo apt install gcc make zlib1g-dev | |
sudo apt install libssl-dev # needed for SSL support | |
sudo apt install libsqlite3-dev # needed for SQLite support | |
sudo apt-get install libbz2-dev # needed for BZ2 compression support | |
wget "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz" | |
tar xJf "Python-$VERSION.tar.xz" | |
cd "Python-$VERSION" |