I tried to compile your code and got this error:
Code: Select all
[ 71%] Building CXX object loop_functions/phero_loop_functions/CMakeFiles/phero_loop_functions.dir/phero_loop_functions.cpp.o
/Users/cpinciroli/Downloads/argos3-examples/loop_functions/phero_loop_functions/phero_loop_functions.cpp:193:13: error:
no member named 'SetRange' in 'argos::CMatrix<500, 500>'
pheroMat.SetRange(PosToIdx(-0.1, 100, 2.5), PosToIdx(0.1, 100, 2.5),
I simply commented the line out to be able to keep going. Then I got this error:
Code: Select all
[ 72%] Linking CXX shared module libphero_loop_functions.so
Undefined symbols for architecture x86_64:
"QFont::QFont()", referenced from:
CPheroQTUserFunctions::DrawInWorld() in phero_qt_user_functions.cpp.o
"QFont::~QFont()", referenced from:
CPheroQTUserFunctions::DrawInWorld() in phero_qt_user_functions.cpp.o
ld: symbol(s) not found for architecture x86_64
This says that you haven't linked your code against the Qt libraries. So I added ${ARGOS_QTOPENGL_LIBRARIES} to loop_functions/phero_loop_functions/CMaleLists.txt:
Code: Select all
if(ARGOS_COMPILE_QTOPENGL)
target_link_libraries(phero_loop_functions argos3plugin_simulator_qtopengl
${ARGOS_QTOPENGL_LIBRARIES})
endif(ARGOS_COMPILE_QTOPENGL)
Then the compilation continued and I got this error:
Code: Select all
[100%] Linking CXX shared library libfootbot_phero.dylib
Undefined symbols for architecture x86_64:
"CPheroLoopFunctions::PosToIdx(double, unsigned int, double)", referenced from:
argos::CFootBotPheroSensor::Update() in footbot_phero_sensor.cpp.o
"argos::CPheroSensorEquippedEntity::ParseType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
argos::CPheroSensorEquippedEntity::Init(ticpp::Element&) in phero_sensor_equipped_entity.cpp.o
"typeinfo for CPheroLoopFunctions", referenced from:
argos::CFootBotPheroSensor::CFootBotPheroSensor() in footbot_phero_sensor.cpp.o
"_lua_getfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_gettable", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_pushnumber", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_setfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_settop", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
As a rule, you should not use the loop functions inside a sensor. The loop functions are meant for experiment-specific code, but your sensor is written as an experiment-agnostic one. Anyway, let's say we keep going with this. I make the following modifications. First, in phero_loop_functions/CMakeList.txt I changed MODULE to SHARED, so you can link libphero_loop_functions.so to libphero_sensor.so:
Code: Select all
add_library(phero_loop_functions SHARED ${phero_loop_functions_SOURCES})
Then I added phero_loop_functions to the list of libraries to link against in phero_sensor/CMakeLists.txt:
Code: Select all
target_link_libraries(footbot_phero
argos3core_simulator
argos3plugin_simulator_footbot
argos3plugin_simulator_genericrobot
phero_loop_functions)
This created a new linking error, namely
Code: Select all
[100%] Linking CXX shared library libfootbot_phero.dylib
Undefined symbols for architecture x86_64:
"argos::CPheroSensorEquippedEntity::ParseType(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
argos::CPheroSensorEquippedEntity::Init(ticpp::Element&) in phero_sensor_equipped_entity.cpp.o
"_lua_getfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_gettable", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_pushnumber", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_setfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_settop", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
Which I fixed by uncommenting lines 156-160 of phero_equipped_entity.cpp. This left me my another linking error:
Code: Select all
Undefined symbols for architecture x86_64:
"_lua_getfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_gettable", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_pushnumber", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_setfield", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
"_lua_settop", referenced from:
argos::CCI_FootBotPheroSensor::ReadingsToLuaState(lua_State*) in ci_footbot_phero_sensor.cpp.o
ld: symbol(s) not found for architecture x86_64
Which I fixed by adding ${LUA_LIBRARIES} to phero_sensor/CMakeLists.txt:
Code: Select all
target_link_libraries(footbot_phero
argos3core_simulator
argos3plugin_simulator_footbot
argos3plugin_simulator_genericrobot
phero_loop_functions
${LUA_LIBRARIES})
With all this, compilation finally works. I tried to run
and the simulator starts correctly.
I strongly suggest you to read about linking errors and CMake before you keep coding with ARGoS, so you learn how to fix these errors yourself.
I made ARGoS.