Git Product home page Git Product logo

r-spaceship-tracking's Introduction

R-spaceship-tracking

Tracking a drifting space ship with predictive control models (which can be implemented) to prove basic control systems.

This is a port from Matlab to R of a previous control project.

Example of running the program

Environment setup

For this simulation there is a spaceship with a broken engine out in space, captained by Major Tom. The task is to implement a rescuing ship that will reach Major Tom before his life support runs out, which will take a certain amount of time steps.

The known parameters of the problem are that Major Tom starts due East of the nearest station at 800 +/- 100 light seconds. The engine propelling him has broken in a fairly predictable way, and he will drift through space on his previous trajectory with some minor disturbances caused by misfires of the engine.

His previous trajectory, combined with the engine leaking, is modeled by a state space of
A = [1.003, -0.009; 0.009, 1.003] (as a matrix)

Combined with that there are misfires from the engine that randomly jostle the craft. This is a random normally distributed system
N([2;0], [4, -0.7; -0.7, 2])

For the rescue ships implemented there are two limiting factors:

  • The argument passed to the ship comes from the ship's sensor. This sensor will be noisy when the rescue ship is moving through space, so only accurate measurements come when it is stationary. It is impractical to stop to get a reading, then go, then stop, continously and thus a predictive kalman filter is a useful control scheme to use.
  • The ships are also subject to drift through space, they are not perfectly constructed so shall also be moved with a random normally distrbuted system:
    N([2;0]. [2, 0; 0, 2])

Ship Implementation

To create a ship to test control schemes with the layout of R6 classes used in R here is quite simple.

Boilerplate code is included in the form of both ships rescue_followalong.R and rescue_random.R

rescue_followalong <- R6Class("rescue_followalong", public = list(
  x = 0,
  y = 0,
  speed = 0,
  direction = 0,
  delayed = FALSE,
  done = Inf,
  initialize = function(x, y) {
    self$x <- x
    self$y <- y
  },
  run = function(position) {
    # Position passed in is the measured position of the adrift ship
    r_to_target <- sqrt((position[1] - self$x)^2 + (position[2] - self$y)^2)
    th_to_target <- 180/pi* atan2(position[2] - self$y, position[1] - self$x)
    
    self$speed <- min(r_to_target, 10)
    self$direction <- th_to_target
  }
))

r-spaceship-tracking's People

Contributors

patricksavill avatar

Stargazers

Hernani Ramos avatar

Watchers

James Cloos avatar Hernani Ramos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.