Get id of the footbot

Requests regarding how to set up experiments in ARGoS.
guiMaitre
Posts: 5
Joined: Mon Mar 04, 2019 9:26 am

Get id of the footbot

Postby guiMaitre » Tue May 21, 2019 12:32 pm

Hello,

I tried to get the ID of my footbot at the end of an experiment. But when I use the argos::CEntity with the function getID() I get a segmentation fault (core dumped).
Since I'm new to c++ (started this week-end) and that I need to rewrite what I have done in LUA to C++. It is certainly an error from my side but I don't find how to do it correctly.

The code I have in my .h file that try to use the faulty code:

Code: Select all

#include <argos3/plugins/robots/foot-bot/simulator/footbot_entity.h> class TestClass : public CCI_Controller { private: CEntity* m_pcEFootBot; }
in my .cpp file that refer to the GetId:

Code: Select all

TestClass::TestClass() : m_pcEFootBot(NULL), void TestClass::Destroy() { std::string m_pcID = m_pcEFootBot->GetId(); //no more segmentation fault if removed std::cout << "stuff ID : " << m_pcID << "\n"; }
I had a similar issue with the exponential function found in argos::CRandom::CRNG but I found an exemple on the website that use so I was able to solve the problem but here I'm kind of lost.
I must be missing something but I don't see what.

Thank for the help.

Waqar731
Posts: 65
Joined: Thu Oct 23, 2014 12:33 pm
Location: Pakistan
Contact:

Re: Get id of the footbot

Postby Waqar731 » Wed Jun 05, 2019 2:49 am

Hi,
Use the following line of code to get the ID of the foot-bot.

Code: Select all

CCI_Controller::GetId()
Because, the controller should not have a CFootBotEntity inside.
Waqar Hussain


Return to “How to... ?”