Page 1 of 1

How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 4:55 am
by Ryan
I tried to show the variable on the top of the robot. But I don't know why I failed.

Code: Select all

void CIDQTUserFunctions::Draw(CFootBotEntity& c_entity) { /* The position of the text is expressed wrt the reference point of the footbot * For a foot-bot, the reference point is the center of its base. * See also the description in * $ argos3 -q foot-bot */ CFootBotPhysarum& cController = dynamic_cast<CFootBotPhysarum&>(c_entity.GetControllableEntity().GetController()); UInt8 type = cController.GetTypeData(); std::string str=std::to_string(type); DrawText(CVector3(0.0, 0.0, 0.3), // position str); // text }
In .h file

Code: Select all

// UInt8 GetTypeData(); inline UInt8 GetTypeData() { return m_robot_type; }

Re: How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 5:31 am
by pincy
What does it mean that you failed?

Re: How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 5:33 am
by Ryan
The terminal as follows:

Code: Select all

std::bad_cast std::bad_cast

Re: How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 5:46 am
by pincy
Have you tried identifying which line causes this?

Re: How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 5:48 am
by Ryan
Yeah

Code: Select all

CFootBotPhysarum& cController = dynamic_cast<CFootBotPhysarum&>(c_entity.GetControllableEntity().GetController());

Re: How to draw the variable by the loop function

Posted: Fri Jan 03, 2020 5:57 am
by pincy
So that means that the controller associated to that robot is not of the type passed to dynamic_cast<>. You can use typeid to debug the issue.