Skip to content

Instantly share code, notes, and snippets.

@zenfiric
Last active September 10, 2019 10:37
Show Gist options
  • Save zenfiric/08176905c03ece0aa4b63c56c6fd8899 to your computer and use it in GitHub Desktop.
Save zenfiric/08176905c03ece0aa4b63c56c6fd8899 to your computer and use it in GitHub Desktop.
The basic differential oscillator used for robots' CPGs in the Revolve project
library(deSolve)
differential_oscilator <- function(t, y, parms) {
with(as.list(c(y, params)), expr = {
dx <- w_yx * y + bias_x
dy <- w_xy * x + bias_y
list(c(dx, dy))
})
}
times <- seq(from = 0, to = 20, by = 0.01)
yini <- c(x = 1, y = 1)
params <- c(w_xy = -1, w_yx = 1, bias_x = 0, bias_y = 0)
out <- ode(times = times, y = yini, func = differential_oscilator, parms = params)
plot(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment