Skip to content

Instantly share code, notes, and snippets.

View tejashah88's full-sized avatar

Tejas Shah tejashah88

View GitHub Profile

ROS 2 - Calculator

Part 1 - Setting up service definitons

  1. Open a new terminal and source the workspace
cd ~/ros2_helloworld_ws
source install/local_setup.bash

Set locale to UTF-8

sudo apt update && sudo apt install locales -y
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

Update system

ROS 2 - Hello World Part 2 - Mouse Sensor

  1. Open a new terminal and source the workspace
cd ~/ros2_helloworld_ws
source install/local_setup.bash
  1. Create a new package

Part 1 - Preparing the workspace

  1. Install needed tools
sudo apt install python3-colcon-common-extensions -y
sudo apt install python3-rosdep2 -y

# !!! NEW Needed Tools !!!
sudo apt install python3-pip
pip install setuptools==58.2.0

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

Part 1 - Preparing the project workspace

  1. Install needed tools
sudo apt install git -y
sudo apt install python3-colcon-common-extensions -y
sudo apt install python3-rosdep2 -y
  1. Create a new directory for your workspace and "change directory" (cd) to it in terminal
@tejashah88
tejashah88 / python-basic-rps-game.py
Created October 20, 2023 00:08
Basic rock-paper-scissors game
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')
@tejashah88
tejashah88 / gen-ssl-files.sh
Created January 29, 2017 06:16
This script allows you to generate the needed SSL certificates and other files.
#!/bin/bash
# Source: OpenSSL Certificate Authority: https://jamielinux.com/docs/openssl-certificate-authority/index.html
# A function which pauses execution until 'Enter' is pressed
# If at least one parameter is given, that parameter will be displayed instead
pause() {
if [ $# -eq 0 ]
then
read -rsp $'Press enter to continue...\n'
@tejashah88
tejashah88 / es6-mode.js
Created June 6, 2018 17:27
An ES6 function to compute the mode(s) of an array. All modes found will return
// Credits go to @Anjuna5 for original code: https://stackoverflow.com/a/39838257/9779148
const mode = arr => [...new Set(arr)]
.map(value => [value, arr.filter((v) => v === value).length])
.sort((a,b) => b[1] - a[1])
.filter((v, i, a) => v[1] === a[0][1])
.map(v => v[0]);