Este script serve para executar a maioria dos passos para execução de teste real usando o grupo de e-pucks do Verlab. Considera-se que está sendo utilizado o silvver para localização usando câmeras e o player para controlar os robôs. Também é considerado que existem 3 bluetooths para comunicar os robôs com o player via o programa rfcommm.
#Parâmetros iniciais:
ROBOTS=2; #número de robôs usados
BLUETOOTH1="00:50:B6:80:14:83"; #Endereços MAC para os três BT usados
BLUETOOTH2="00:15:83:45:2F:AF";
BLUETOOTH3="00:15:83:44:37:E7";
#Número da câmera utilizada. Exemplo: 1 se a camera estiver em /dev/video1
CAMERA=1
#extrair o extrinseco
if [ ! -e scene.lua ] ; then
echo "************************************************************"
echo "* Coloque o e-puck com marco 1 no centro do eixo XY *"
echo "* e aperte ENTER. *"
echo "************************************************************"
read
#Rodar em um terminal
xterm -e "silvver_server -l &> silvver_cfg/log_camera" &
#Roda em outro
xterm -e "silvver_cameras -c silvver_cfg/scene_noExt.$CAMERA.lua" &
sleep 6
killall silvver_server silvver_cameras xterm
tail -n+15 silvver_cfg/log_camera | head -n-2 | sed 's/^([0-9]\+, [0-9]\+)//g' > silvver_cfg/P1_camera
silvverExtCalib -o silvver_cfg/P1_camera > silvver_cfg/scene_middle
head -n 15 silvver_cfg/scene_noExt.$CAMERA.lua > silvver_cfg/scene_head
cat silvver_cfg/scene_head silvver_cfg/scene_middle silvver_cfg/scene_end > scene.lua
fi
##Chamar o server e a camera com args default
xterm -e silvver_server -l &
xterm -e silvver_cameras &
#Chamar os rfcomms
for ((num=0;num<$ROBOTS;num++)); do
if [ ! -e /dev/rfcomm$num ]; then
if [ $num -lt 5 ]; then
xterm -e "rfcomm -f rfcomm.conf -i $BLUETOOTH1 connect $num" &
elif [ $num -lt 9 ]; then
xterm -e "rfcomm -f rfcomm.conf -i $BLUETOOTH2 connect $num" &
else
xterm -e "rfcomm -f rfcomm.conf -i $BLUETOOTH3 connect $num" &
fi
echo "OK for rfcomm$num"
read
fi
done
# OK é 1 se todos os arquivos rfcomm foram criados
OK=0;
for ((num=0;num<$ROBOTS;num++)); do
if [ -e /dev/rfcomm$num ]; then
OK=1;
else
OK=0;
break;
fi
done
#Chama o player se todos rfcomms foram abertos
if [ $OK -eq 1 ]; then
testar-player.sh $ROBOTS
else
end.sh
fi
require("silvver")
prefix_dir = '/usr/local/share/doc/silvver/'
scene = {
cameras = {
V4l2{
silvver_uid = 1,
uid = 1,
focal_length = {675.131408691, 675.236083984},
principal_point = {411.823852539, 277.326599121},
radial_coef = {0.0514593161643, -0.162268817425, 0.0},
tangential_coef = {0.00103016220964, 0.00366096501239},
color_mode = 'yuyv',
resolution = {800,600},
},
},
targets = {
ARTKP{
pattern_width = 50,
silvver_uid = 1,
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_1.patt',
uid = 1,
},
},
},
}
color_mode = 'yuyv',
resolution = {800,600},
},
},
targets = {
ARTKP{
pattern_width = 50,
silvver_uid = 1,
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_1.patt',
uid = 1,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_2.patt',
uid = 2,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_3.patt',
uid = 3,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_4.patt',
uid = 4,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_5.patt',
uid = 5,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_6.patt',
uid = 6,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_7.patt',
uid = 7,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_8.patt',
uid = 8,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_9.patt',
uid = 9,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_10.patt',
uid = 10,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_11.patt',
uid = 11,
},
{
pattern_file = prefix_dir .. 'scenes/artkpImgs/4x4patt/4x4_12.patt',
uid = 12,
},
},
},
}
#
# RFCOMM configuration file.
#
rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D8:27;
# Description of the connection
comment "epuck_1585";
}
rfcomm1 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D8:20;
# Description of the connection
comment "epuck_1573";
}
rfcomm2 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D8:5F;
# Description of the connection
comment "epuck_1543";
}
rfcomm3 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:EC:A7;
# Description of the connection
comment "epuck_1553";
}
rfcomm4 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:EC:71;
# Description of the connection
comment "epuck_1555";
}
rfcomm5 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D8:1E;
# Description of the connection
comment "epuck_1570";
}
rfcomm6 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:52:D1:0B;
# Description of the connection
comment "epuck_1106";
}
rfcomm7 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D7:E8;
# Description of the connection
comment "epuck_1571";
}
rfcomm8 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:52:A9:69;
# Description of the connection
comment "epuck_1107";
}
rfcomm9 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D7:BD;
# Description of the connection
comment "epuck_1554";
}
rfcomm10 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D7:E6;
# Description of the connection
comment "epuck_1589";
}
rfcomm11 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 10:00:E8:6C:D7:C8;
# Description of the connection
comment "epuck_1593";
}
Primeiro o script verifica se no diretório atual não existe um arquivo com nome scene.lua. Este arquivo é usado pelo silvver e contém todas as informações sobre parâmetros intrínsecos e extrínsecos da câmera e marcos usados pelo ARToolKit. Caso não existe, ele cria um executando o silvver_cameras usando um
arquivo de configuração padrão que deve se encontrar na pasta silvver_cfg no mesmo diretório onde está o script. O arquivo de configuração padrão tem nome scene_noExt.1.lua caso a camera esteja em /dev/video1. Copie este arquivo ou mude o nome para scene_noExt.0.lua caso este usando uma camera em /dev/video0. O arquivo scene_end contém as definições dos marcos para o ARToolKit.
Para os três bluetooths indicados pelo endereço MAC (BLUETOOTH1, BLUETOOTH2 e BLUETOOTH3) são conectados alguns robôs. O arquivo rfcomm.conf mapeia o endereço MAC dos e-pucks com os marcos que já foram colocados acima deles. Se todos os robôs foram corretamente conectados, é disparado o player com suas configurações desejadas.
Os arquivos para o silvver mostrados correspondem a versão 0.6. Caso utilize outra versão, a sintaxe deve ser modificada.
O rfcomm, em alguns sistemas operacionais, necessita ser usado em conjunto com sudo. Use sudo -S para pegar a senha automaticamente de um arquivo, via pipeline. Ex: cat arquivoComSenha | sudo -S rfcomm ….