visionlabels / motrack

Tools for Multiple Object Tracking experiments
https://visionlabels.github.io/motrack/
GNU General Public License v3.0
8 stars 2 forks source link

Objects can move outside the arena/into each other #13

Open fidadoma opened 4 years ago

fidadoma commented 4 years ago

When generating trajectories, objects can move outside the arena. The probable cause is the order of the bouncing corrections and step_functions (bouncing corrections change the direction, but the step size function can move) in function make_random_trajectory

if (settings$bounce_off_square) {
      moment <- bounce_off_square(moment, timescale[i], settings)
    }
    if (settings$bounce_off_circle) {
      moment <- bounce_off_circle(moment, timescale[i], settings)
    }
    if (settings$bounce_off_inside) {
      moment <- bounce_off_inside(moment, timescale[i], settings)
    }
    if (settings$bounce_off_others) {
      moment <- bounce_off_others(moment, timescale[i], settings)
    }
    moment_next <- step_function(moment, timescale[i], settings, ...)

Following code reproduces the error

spd <- 5
xlims_move <- c(-9,9)
ylims_move <- c(-9,9)
sett_generate <-
  new_settings(xlim = c(-7, 7), ylim = c(-7, 7), min_distance = 2,
               arena_shape = "circle")
# they can move in a circular arena, bounce off borders and other objects
sett_move <-
  new_settings(xlim = xlims_move, ylim = ylims_move,
               bounce_off_square = F,
               bounce_off_circle = T, circle_bounce_jitter = pi / 6,speed = spd)

set.seed(1001)

position <- generate_positions_random(8, sett_generate)

timescale <- seq(0, 8, by = 0.1)

trajectory_z <- 
  make_random_trajectory(position, timescale, sett_move, 
                         step_zigzag, ttt = c(.5, 1.5), syncstart = F)

dist_z <- sqrt((trajectory_z$x^2+trajectory_z$y^2))

max(dist_z) < max(xlims_move)
fidadoma commented 4 years ago

@jirilukavsky What if we add code that would check that does not break some constraints (otherwise regenerate this step)moment_next <- step_function(moment, timescale[i], settings, ...) ?

jirilukavsky commented 4 years ago

I am aware of this. So far, the problem was approached by using very small time steps (1/100 s) and adding extra values for bouncing limits (e.g., 2.05 deg instead of 2.0 deg). The problem is that some step_functions are deterministic, so regenerating does not solve the problem.