Bug #402
closedreinitializing ftsens module
Description
Hi Anthony,
The problem that is that when I first initialize the module it works fine, if I reinitialize it, it will not work.
How to replicate the problem:
1. I run the following script (start.sh in the attachments):
#!/bin/bash
# Run this script before you run the tutorial in MATLAB
# It will start the simulation in Gazebo with the low friction wall &
# launch all the required genom modules
# Closes all Genom3 modules
pkill genomixd &
pkill mrsim-pocolibs &
pkill optitrack-pocolibs &
pkill pom-pocolibs &
pkill rotorcraft-pocolibs &
pkill ftsens-pocolibs &
h2 end
sleep 1
h2 init
sleep 1
genomixd &
sleep 1
tk3-mux /dev/ttyACM1 & ~/ut-tools/manual-install/ftsens-genom3/build/pocolibs/server/ftsens-pocolibs -f && fg
and the output will looks like:
Removing pocolibs devices: tUnix5257:
h2devEnd: S_h2devLib_NOT_INITIALIZED
Initializing pocolibs devices: OK
tk3-mux: connected to /dev/ttyACM1
ftsens: created outport ftsens/genom_state
ftsens: created outport ftsens/genom_metadata
ftsens: created outport ftsens/wrench
ftsens: spawned task read
ftsens: spawned control task
ftsens: setup and running
then in MATLAB I run the following (ftsens_tutorial.m in the attachments):
clear; clc;
% add genomix-matlab path
setenv('ROBOTPKG_BASE','/home/ayham/ut-tools/openrobots')
addpath(strcat(getenv('ROBOTPKG_BASE'),'/lib/matlab'));
addpath(strcat(getenv('ROBOTPKG_BASE'),'/lib/matlab/simulink'));
addpath(strcat(getenv('ROBOTPKG_BASE'),'/lib/matlab/simulink/genomix'));
ft_sens_plugin_path = '/lib/genom/pocolibs/plugins/';
host = 'localhost';
% Initialize GenoM stuff and connect the ports %
% --------------------------------------------------
disp('Initialize genom components for simulation');
client = genomix.client(host);
disp('* Initialize ft-sensor');
ftsens = client.load(strcat(ft_sens_plugin_path,'ftsens'));
pause(1);
result_ft = ftsens.connect('/tmp/can', 1000);
stringmsg = ['Connecting to ftsens: ',result_ft.status];
disp(stringmsg);
result_ft = ftsens.set_zero(5000);
stringmsg = ['Zeroing the FT-sensor: ',result_ft.status];
disp(stringmsg);
result_ft = ftsens.wrench();
stringmsg = ['FT-sensor reading: ',num2str(result_ft.wrench.force.x),...
', ', num2str(result_ft.wrench.force.y), ', ', num2str(result_ft.wrench.force.z)];
disp(stringmsg);
This will work, and the terminal output will be:
Removing pocolibs devices: tUnix5257:
h2devEnd: S_h2devLib_NOT_INITIALIZED
Initializing pocolibs devices: OK
tk3-mux: connected to /dev/ttyACM1
ftsens: created outport ftsens/genom_state
ftsens: created outport ftsens/genom_metadata
ftsens: created outport ftsens/wrench
ftsens: spawned task read
ftsens: spawned control task
ftsens: setup and running
ftsens-pocolibs: SIOCGIFINDEX /tmp/can: No such device
ftsens-pocolibs: found strain2 as node 13
node 13: type 0c
version: 2.0.9
CAN protocol version: 2.0
while matlab outputs:
Initialize genom components for simulation
* Initialize ft-sensor
Connecting to ftsens: done
Zeroing the FT-sensor: done
FT-sensor reading: -0.36621, 0.091553, 0.18311
now if I run the ftsens_tutorial.m matlab script again, it will get stuck and when I kill the terminal I will see the following:
Removing pocolibs devices: tUnix5257:
h2devEnd: S_h2devLib_NOT_INITIALIZED
Initializing pocolibs devices: OK
tk3-mux: connected to /dev/ttyACM1
ftsens: created outport ftsens/genom_state
ftsens: created outport ftsens/genom_metadata
ftsens: created outport ftsens/wrench
ftsens: spawned task read
ftsens: spawned control task
ftsens: setup and running
ftsens-pocolibs: SIOCGIFINDEX /tmp/can: No such device
ftsens-pocolibs: found strain2 as node 13
node 13: type 0c
version: 2.0.9
CAN protocol version: 2.0
ftsens-pocolibs: SIOCGIFINDEX /tmp/can: No such device
^Cftsens: terminating on Interrupt signal request
tk3-mux: terminating
ftsens-pocolibs: found strain2 as node 13
node 13: type 0c
version: 2.0.9
CAN protocol version: 127.0
if I start a new terminal and run the start.sh script again, and try to initialize from Matlab again using ftsens_tutorial.m, I get the following in the terminal:
Removing pocolibs devices: OK
Initializing pocolibs devices: OK
tk3-mux: connected to /dev/ttyACM1
ftsens: error creating /home/ayham/.ftsens.pid-ayham: File exists
ftsens: forcibly disabling the protection against duplicate instances
ftsens: cleaning pocolibs ftsens device
tUnix6933: No matching device
ftsens: cleaning pocolibs ftsens/* devices
tUnix6933: No matching device
ftsens: created outport ftsens/genom_state
ftsens: created outport ftsens/genom_metadata
ftsens: created outport ftsens/wrench
ftsens: spawned task read
ftsens: spawned control task
ftsens: setup and running
ftsens-pocolibs: SIOCGIFINDEX /tmp/can: No such device
tk3-mux: hardware error: can bus error
ftsens-pocolibs: can't find strain2 node
then I kill the terminal and I see this in MATLAB:
Error using ftsens::set_zero
connection closed
Please let me know if you have any questions.
Thanks!
Ayham
Files