Bad Cast on Two Different Footbot Controllers

Requests regarding how to set up experiments in ARGoS.
dtzl1999
Posts: 1
Joined: Tue Oct 20, 2020 6:43 am

Bad Cast on Two Different Footbot Controllers

Postby dtzl1999 » Tue Nov 10, 2020 9:41 am

I have some issue with dynamic cast for the loop function that I have created. Here is a part pertaining to the dynamic cast:

Code: Select all

CFootBotEntity& footBot = *any_cast<CFootBotEntity*>(it->second); CFootBotMobile& controller = dynamic_cast<CFootBotMobile&>(footBot.GetControllableEntity().GetController());
Besides that, I have deduced the issue behind the std::bad_cast error and able to reproduce it. The fault lies in the fact that I used two different footbot controllers within my xml file. Hence, the only way of fixing it is using only one of the controllers at a time but the setup that I am planning requires those two controllers to work.

I am wondering if there is any suggestion to solve this issue?

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

Re: Bad Cast on Two Different Footbot Controllers

Postby pincy » Tue Nov 10, 2020 9:54 am

Instead of casting to reference, cast to pointer and check whether the pointer is null or not.
I made ARGoS.


Return to “How to... ?”