Skip to content

Instantly share code, notes, and snippets.

View adityakamath's full-sized avatar
🤖
Building on weekends

Aditya Kamath adityakamath

🤖
Building on weekends
View GitHub Profile
@adityakamath
adityakamath / setup_rtimulib.sh
Last active September 2, 2023 20:52
Setup RTIMULIb and IMU devices on RPi4
#!/bin/bash
# Ref: https://github.com/J-Pai/EnvTrackerNode/tree/master
# Development setup including support for cross-compilation
# to AArch64, runtime dependencies and tools
sudo apt install python3 python3-dev python3-pip python3-venv \
build-essential autoconf libtool bear \
pkg-config cmake libssl-dev libsasl2-dev \
openssl libcurl4-openssl-dev libc++-dev \
@adityakamath
adityakamath / imu_test.py
Last active September 2, 2023 17:20
RTIMULib IMU test
import os
import time
import math
import RTIMU
from copy import deepcopy
class IMUSensor:
def __init__(self, imu_settings_file='RTIMULib'):
self._imu_settings = self._get_settings_file(imu_settings_file)
self._imu = RTIMU.RTIMU(self._imu_settings)
@adityakamath
adityakamath / fastdds_tailscale_discovery.xml
Last active August 26, 2023 17:34
Tailscale FastDDS Discovery Server
<?xml version="1.0" encoding="UTF-8" ?>
<dds>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<participant profile_name="TailscaleDiscoveryServer" is_default_profile="true">
<rtps>
<builtin>
<discovery_config>
<discoveryProtocol>SUPER_CLIENT</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
@adityakamath
adityakamath / fastdds_tailscale_simple.xml
Last active August 26, 2023 17:35
Tailscale FastDDS Simple Discovery
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>TailscaleTransport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="TailscaleSimple" is_default_profile="true">
<rtps>
@adityakamath
adityakamath / executor_composed.py
Created June 3, 2023 09:04
ros2 executor composed example
# 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,
@adityakamath
adityakamath / optical_flow_equation.py
Last active June 3, 2023 09:28
PMW3901/PAA5100 optical flow pixel to distances
# h = height/altitude of the sensor from ground
# fov = field of view of the sensor in radians
# res = resolution of the sensor in pixels
# scaler = scaling factor
# dt = time period of this loop
conversion_factor = h*2*np.tan(fov/2)/(res*scaler)
if 'paa5100':
# Convert data from sensor frame to ROS frame for PAA5100
@adityakamath
adityakamath / optical_flow_launch.py
Created June 3, 2023 08:49
ros2 python launch file example for lifecycle node
from launch import LaunchDescription
from launch.actions import EmitEvent, RegisterEventHandler
from launch.events import matches_action
from launch_ros.actions import LifecycleNode
from launch_ros.event_handlers import OnStateTransition
from launch_ros.events.lifecycle import ChangeState
from lifecycle_msgs.msg import Transition
def generate_launch_description():
ld = LaunchDescription()
@adityakamath
adityakamath / t265_ekf_params.yaml
Created October 3, 2021 12:03
robot_localization sample config file
# The frequency, in Hz, at which the filter will output a position estimate. Note that the filter will not begin
# computation until it receives at least one message from one of the inputs. It will then run continuously at the
# frequency specified here, regardless of whether it receives more measurements. Defaults to 30 if unspecified.
frequency: 60
# The period, in seconds, after which we consider a sensor to have timed out. In this event, we carry out a predict
# cycle on the EKF without correcting it. This parameter can be thought of as the minimum frequency with which the
# filter will generate new output. Defaults to 1 / frequency if not specified.
sensor_timeout: 0.05
@adityakamath
adityakamath / potential_fields
Created June 17, 2016 19:20
potential_fields_snippet
void potential_fields() {
// these are the coordinates of the setpoint and the current position of the robot
// normally xr should be zero, equal to x0 (origin right in the center of the corridor)
// and y0 must have a value
float theta, phi, r = 1, Fatt_x, Fatt_y, Ftot_x, Ftot_y, Frep_x = 0, Frep_y = 0, Frep = 0, xr = 0, yr = 0, xs = 0.1, ys = 0;
Fatt_x = ws * (xs - xr);
Fatt_y = ws * (ys - yr);
@adityakamath
adityakamath / virtual_wall_function
Last active June 1, 2020 02:28
virtual_wall_function
void adjust_LRF() {
for (unsigned int i = 0; i < scan.ranges.size(); ++i) { // i choose 0.01 because the invalid LRF are small negative and positive values
if (decision_variable == 1 || turning_left) { // left turn
if (i < 350) scan.ranges[i] = block_distance;
else if (scan.ranges[i] < 0.01 || scan.ranges[i] > radius_value || scan.ranges[i] != scan.ranges[i]) scan.ranges[i] = radius_value;
}
else if (decision_variable == 2 || turning_right) { // right turn
if (i > 650) scan.ranges[i] = block_distance;
else if (scan.ranges[i] < 0.01 || scan.ranges[i] > radius_value || scan.ranges[i] != scan.ranges[i]) scan.ranges[i] = radius_value;