How to draw the variable by the loop function

Requests regarding how to set up experiments in ARGoS.
Ryan
Posts: 42
Joined: Wed Oct 23, 2019 3:26 am

How to draw the variable by the loop function

Postby Ryan » Fri Jan 03, 2020 4:55 am

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; }

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: How to draw the variable by the loop function

Postby pincy » Fri Jan 03, 2020 5:31 am

What does it mean that you failed?
I made ARGoS.

Ryan
Posts: 42
Joined: Wed Oct 23, 2019 3:26 am

Re: How to draw the variable by the loop function

Postby Ryan » Fri Jan 03, 2020 5:33 am

The terminal as follows:

Code: Select all

std::bad_cast std::bad_cast

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: How to draw the variable by the loop function

Postby pincy » Fri Jan 03, 2020 5:46 am

Have you tried identifying which line causes this?
I made ARGoS.

Ryan
Posts: 42
Joined: Wed Oct 23, 2019 3:26 am

Re: How to draw the variable by the loop function

Postby Ryan » Fri Jan 03, 2020 5:48 am

Yeah

Code: Select all

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

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: How to draw the variable by the loop function

Postby pincy » Fri Jan 03, 2020 5:57 am

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.
I made ARGoS.


Return to “How to... ?”