#!/bin/bash

dataset="$1"
method="mcl1"

source script_variables.sh

#trick for fixing the LD_LIBRARY_PATH
export LD_LIBRARY_PATH=../src/mcl/lib

# This is the "Frozen Time" MCL ( aka "Fuck The MCL" ). It computes the INITIAL pose of the robot.
# It does that by storing, for each particle, its initial position. Maybe it's an hack, maybe not...
# My suspect is that it is extremely overconfident.

# Use -neff 2 to have the SIR filter, -neff 0 to never resample

mkdir -p ${chunk_dir}/${method}
for chunk in ${chunk_dir}/???.clf; do
	chunk_id=`basename ${chunk} .clf`
	prefix="${chunk_dir}/${method}/${chunk_id}"

	if [ -e ${prefix} ]; then
		echo "File ${prefix} already exists; delete it to run the method again."
	else
	${mcl_loc} -mapfile "${dataset}_map/${dataset}.map.png" -filename ${chunk} -writeJson ${prefix} \
		-nognuplot \
		$(awk '{print "-"$0"\\"}' ${dataset}_map/${dataset}_bbox.txt) \
		-poseType 0 \
		-neff 2 \
		-particles 10000 \
		-sigma 0.5 \
		-skip 1 \
		-unknown 10000 \
		-srr 0.1 -srt 0.1 -str 0.1 -stt 0.1
	fi
done

method="mcl2"
# This is the "Frozen Time" MCL v 2.0 ( aka "Fuck The MCL" ). It computes the INITIAL pose of the robot.
# It does that by computing, for each particle, its initial position by using the Scan Matcher displacement. 

mkdir -p ${chunk_dir}/${method}

for chunk in ${chunk_dir}/???.clf; do
	chunk_id=`basename ${chunk} .clf`
	prefix="${chunk_dir}/${method}/${chunk_id}"

	if [ -e ${prefix} ]; then
		echo "File ${prefix} already exists; delete it to run the method again."
	else
	${mcl_loc} -mapfile "${dataset}_map/${dataset}.map.png" -filename ${chunk} -writeJson ${prefix} \
		-nognuplot \
		$(awk '{print "-"$0"\\"}' ${dataset}_map/${dataset}_bbox.txt) \
		-poseType 1\
		-neff 2 \
		-particles 10000 \
		-sigma 0.5 \
		-skip 1 \
		-unknown 10000 \
		-srr 0.1 -srt 0.1 -str 0.1 -stt 0.1
	fi
done


