addLuaPackagePath() does not add the path
I'm developing a ROS node for running a fsm using rfsmTools. The ROS node is in its own folder in a catkin workspace. I compiled rfsmTools with the -DEMBED_RFSM=OFF flag since i already had rfsm on my pc. Lua version is 5.2. Since the lua file of the fsm is in a custom folder, I added the following code to my ROS node:
rfsm.addLuaPackagePath("/home/alessio/catkin_ws/src/fsm_controller/fsm/?.lua");
rfsm.load("prova_fsm.lua");
but when i run the code i get this error:
[ERROR] cannot open prova_fsm.lua: No such file or directory stack traceback: [C]: in function 'dofile' /home/alessio/libraries/rFSM/rfsm.lua:214: in function 'load' [string "fsm_model"]:1: in main chunk [ERROR]Lua has not been initialized. call StateMachine::load() [ERROR]Lua has not been initialized. call StateMachine::load() [ERROR]Lua has not been initialized. call StateMachine::load()
I checked multiple times the path to the fsm and it is correct. Moreover, if i place the "prova_fsm.lua" file in my home directory the code works well (even without using addLuaPackagePath()) . I checked the LUA_PATH variable after running the code and it does not have the path i try to add with addLuaPackagePath() (i'm expecting the path should be there but i'm not sure about it, i add this info for sake of completeness). I tried to find a workaround to the problem by adding the path of the fsm manually to the LUA_PATH variable but with no effect so honestly i don't know if it is only a addLuaPackagePath() issue or there are multiple issues somewhere in my setup.
Hi @sozzialessio ,
I added the following code to my ROS node: rfsm.addLuaPackagePath("/home/alessio/catkin_ws/src/fsm_controller/fsm/?.lua"); rfsm.load("prova_fsm.lua");
Is it c++ code? are you using the c++ library librfsm ?
From your error it seems that it can't find the .lua file containing the state machine, pay attention where it is and where are you running your executable.
I checked multiple times the path to the fsm and it is correct. Moreover, if i place the "prova_fsm.lua" file in my home directory the
My guess is that you are running your executble from the home directory and in that foldere prova_fsm.lua is present
Hi @Nicogene, Thank you for your answer.
I added the following code to my ROS node: rfsm.addLuaPackagePath("/home/alessio/catkin_ws/src/fsm_controller/fsm/?.lua"); rfsm.load("prova_fsm.lua");
Is it c++ code? are you using the c++ library
librfsm?
Yes, it is c++ code and yes, i'm using librfsm. I'm following closely the main.cpp that you provide in the example folder of rfsmTools to know how to use the functions properly.
From your error it seems that it can't find the
.luafile containing the state machine, pay attention where it is and where are you running your executable.I checked multiple times the path to the fsm and it is correct. Moreover, if i place the "prova_fsm.lua" file in my home directory the
My guess is that you are running your executble from the home directory and in that foldere
prova_fsm.luais present
Yes, indeed i was running the code in the same folder where the prova_fsm.lua was. I made some test running the code in another folder and the file can't be found.
The problem is that i need to run the code in a different folder from the one containing the fsm so i need a way to make the program search the fsm in the correct folder. It seems that addLuaPackagePath() is failing in that.