Skip to content

Instantly share code, notes, and snippets.

View linknum23's full-sized avatar

Lincoln Lorenz linknum23

  • MicroNova
  • United States
View GitHub Profile
@linknum23
linknum23 / bugs.c
Created November 30, 2016 19:13
Bugs to Remember
void unsignedReverseIteration(){
unsigned int chan;
// for some odd reason you decide to reverse iterate
for(chan=31; chan >= 0 ; chan--){
// logic, that executes forever in a loop, because chan is never less than 0
}
// code doesn't ever get here!
}
@linknum23
linknum23 / CMakeLists.txt
Created June 21, 2017 17:42
CMakeList configuration for compiling ROS and Driveworks on a Tegra (Drive PX2)
cmake_minimum_required(VERSION 3.1)
project(dw_wrapper)
set (CMAKE_CXX_STANDARD 11)
# FindDriveworks.cmake, ArchConfiguration.cmake, and LibFindMacros.cmake were needed for my setup they are taken from driveworks/samples/cmake/
# ArchConfiguration.cmake was the only file that needed small changes, remove the fatal error on line 17 and add the following lines in its place
# set(VIBRANTE TRUE)
# add_definitions(-DVIBRANTE)
# this is the path I placed the driveworks cmake files in
@linknum23
linknum23 / config_shell.bash
Last active June 30, 2017 19:24
Warn user to source bash script to keep environment variable changes
#!/bin/bash
# idea from: https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
[[ "${BASH_SOURCE[0]}" != "${0}" ]] || echo -e "\e[31m""${BASH_SOURCE[0]} needs sourced to set the environment variables in this shell""\e[0m"
#set environment variables
@linknum23
linknum23 / build_opencv.bash
Created June 23, 2017 21:31
Building opencv on the Drive PX 2
#!/bin/bash
# fresh start
rm -rf build_opencv
mkdir build_opencv
# grab all of opencv
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_extra.git
# git clone https://github.com/opencv/opencv_contrib.git
#!/bin/bash
# some silly programs force themselves to output to /dev/tty this makes it messy for scripts that call them
# heres a way to workaround this issue
script --command `pwd`/what_i_wanted_to_do.bash /dev/null >> output.log
@linknum23
linknum23 / single_function.c
Created July 8, 2017 20:48
Set the optimization level of a single c function in gcc
// You can use a Function Attribute called optimize to do this.
// I got the info on Function Attributes from this link:
// https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Function-Attributes.html#Function-Attributes
// To set the optimization level to -O0 for a function:
void __attribute__ ((optimize("-O0"))) foo() {}
#!/bin/bash
# modification of https://github.com/fearside/ProgressBar/
# 1. Create ProgressBar function
# 1.1 Input is currentState($1) and totalState($2)
function ProgressBar {
# Process data
let _progress=(${1}*100/${2}*100)/100
let _done=(${_progress}*4)/10
@linknum23
linknum23 / bash_nmcli_wifi_aliases.bash
Created September 20, 2017 16:50
bash nmcli wifi aliases
# nmcli aliases from man nmcli
alias wifi-list='nmcli dev wifi list'
alias wifi-connect='nmcli con up id'
alias wifi-add='nmcli --ask dev wifi connect '
@linknum23
linknum23 / replay_bag_1khz.launch
Last active March 6, 2018 19:18
Launching 1KHz bagfile playback
<?xml version="1.0"?>
<launch>
<arg name="play_bag" default="true"/>
<arg name="uut" default="my_node"/>
<param name="use_sim_time" value="true"/>
<arg name="bag_file" value="$(env HOME)/.ros/my_bag.bag"/>
<node pkg="my_pkg" type="$(param uut)" name="$(param uut)_node" output="screen"/>
<!-- NOTE: standard rosbag published clock rate of 100Hz, was too slow for my ros timer callbacks -->
<!-- Produce a clock, using the bagfile, at 1KHz to make timer callbacks up to a KHz work! -->
@linknum23
linknum23 / upgrade_xc32.bash
Last active July 2, 2018 17:59
upgrade microchip x32 peripheral libraries without peripheral libraries executable ( assumes 1.40 is installed and has peripheral libraries )
#!/bin/bash
read -p "compiler version: " version
if [ ! -e /opt/microchip/xc32/v$version ] ; then
echo "directory /opt/microchip/xc32/v$version not found"
echo "not an installed version"
return 2>/dev/null || exit
fi
mkdir -p /opt/microchip/xc32/v${version}/pic32-libs/include/lega-c