Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@contradict
contradict / limited_oscillator.jl
Created December 1, 2021 00:59
ModelingToolkit.jl mechanical example.
using ModelingToolkit, OrdinaryDiffEq
@variables t
D = Differential(t)
"The basic unit of the mechanical systems is a body with a position and a force"
@connector function Body(; name)
sts = @variables x(t) F(t)
ODESystem(Equation[], t, sts, []; name = name)
@contradict
contradict / Stack Trace
Last active November 27, 2020 23:21
Error using ModelingToolkit
julia> include("example.jl")
ERROR: LoadError: Failed to apply rule ~(z::_isone) * ~x => ~x on expression (1 * sqrt((((2 * Pin) / Tin) * Pin) * (((Pb(t) / Pin) ^ 2) - ((Pb(t) / Pin) ^ 3)))) * (1 * ifelse(signbit(0.07 - abs(u(t))), (tanh((((abs(u(t)) - 0.07) / 0.9299999999999999) * 2) + -1) - -0.7615941559557649) / 1.5231883119115297, 0))
Stacktrace:
[1] (::SymbolicUtils.Rule{Term{Any},SymbolicUtils.var"#term_matcher#46"{Tuple{SymbolicUtils.var"#literal_matcher#42"{typeof(*)},SymbolicUtils.var"#slot_matcher#43"{SymbolicUtils.Slot{typeof(SymbolicUtils._isone)}},SymbolicUtils.var"#slot_matcher#43"{SymbolicUtils.Slot{typeof(SymbolicUtils.alwaystrue)}}}},SymbolicUtils.var"#101#170"})(::Term{Number}) at /home/russel/.julia/packages/SymbolicUtils/K1sGK/src/rule.jl:142
[2] (::SymbolicUtils.ACRule{typeof(Combinatorics.combinations),SymbolicUtils.Rule{Term{Any},SymbolicUtils.var"#term_matcher#46"{Tuple{SymbolicUtils.var"#literal_matcher#42"{typeof(*)},SymbolicUtils.var"#slot_matcher#43"{SymbolicUtils.Slot{typeof(Symb
@contradict
contradict / MultipleUnstack.jl
Last active September 22, 2020 18:42
How to unstack multiple columns with Julia DataFrames.
### A Pluto.jl notebook ###
# v0.11.9
using Markdown
using InteractiveUtils
# ╔═╡ d10371f6-e94c-11ea-0309-5788d6e340b3
begin
using Pkg
Pkg.activate(".")

Keybase proof

I hereby claim:

  • I am contradict on github.
  • I am contradict (https://keybase.io/contradict) on keybase.
  • I have a public key ASAiwRE_g0yCQZVvs-Po0TYHBgc94ADWgRFRufT3-2JyUgo

To claim this, I am signing this object:

@contradict
contradict / test.cpp
Created July 11, 2016 02:16
Projecting to yaw only
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Geometry>
#include <sophus/so3.hpp>
#include <cmath>
// compile with
// g++ -I /usr/include/eigen3 test.cpp -lm -o test
int main(int argc, char **argv)
@contradict
contradict / yaml_send.py
Created May 1, 2015 05:57
yaml over ros topic
#!/usr/bin/env python
# run the receiver:
# $ ./yaml_send.py
#
# run the transmitter:
# $ ./yaml_send.py send <myfile.yaml>
import yaml
import sys
import rospy
@contradict
contradict / gist:6c89a4feec8703c76fce
Last active August 29, 2015 14:18
Derivative with noise
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
# generate some example data
t = np.linspace(0, 1, 1000)
# interesting temperature profile
temperature = 10*(t-0.4)*(t-0.2)*(t-0.8) + 2.0
# with exact derivative
dtempdt = 10*((t-0.2)*(t-0.8) + (t-0.4)*(t-0.8) + (t-0.4)*(t-0.2))
compile with
g++ -I/opt/ros/indigo/include -I/usr/include/python2.7 python_costmap2d.cpp -fPIC --shared -L/opt/ros/indigo/lib -lcostmap_2d -lpython2.7 -lboost_python -o costmap2d_ext.so