tud-cor / FS19_modROS

(partial) ROS1 integration for FarmSim19
Apache License 2.0
49 stars 12 forks source link

rosPubMsg: attempt to index field 'vehicle' (a nil value) #25

Closed gavanderhoorn closed 3 years ago

gavanderhoorn commented 3 years ago

After following the installation instructions, starting FS19, not getting in any vehicle and then immediately executing rosPubMsg true in the game console gets me this:

2021-06-03 16:47 Error: Running LUA method 'rosPubMsg'.
2021-06-03 16:47 C:/Users/user/Documents/My Games/FarmingSimulator2019/mods/modROS/modROS.lua:506: attempt to index field 'vehicle' (a nil value)
2021-06-03 16:47 Warning (script): 'localToWorld': Argument 1 has wrong type. Expected: Int. Actual: Nil 
2021-06-03 16:47   ..\..\..\src\base\scripting\lua\LuaScriptSystem.cpp (882): expectedType == Value::VoidType || expectedType == Value::ClassType
2021-06-03 16:47 LUA call stack:
2021-06-03 16:47   =C:/Users/user/Documents/My Games/FarmingSimulator2019/mods/modROS/modROS.lua (298) : localToWorld
2021-06-03 16:47   =C:/Users/user/Documents/My Games/FarmingSimulator2019/mods/modROS/modROS.lua (115) : publish_laser_scan_func
2021-06-03 16:47   dataS/scripts/BaseMission.lua (1599) : update
2021-06-03 16:47   dataS/scripts/FSBaseMission.lua (1979) : update
2021-06-03 16:47   dataS/scripts/missions/mission00.lua (469) : update
2021-06-03 16:47   dataS/scripts/main.lua (1944) : update

the line mentioned is here:

https://github.com/tud-cor/FS19_modROS/blob/0424021c54f95efb26e6a6cef709a7ad547cf61e/modROS.lua#L504-L506

the error makes sense: I'm not in a vehicle, so g_currentMission.controlledVehicle is nil.