e-puck range and bearing

Requests regarding how to set up experiments in ARGoS.
elriden
Posts: 2
Joined: Thu Dec 03, 2015 12:10 am

e-puck range and bearing

Postby elriden » Thu Mar 10, 2016 12:40 am

Hello,
I'm trying to simulate the way a fire spreads on a forest using the e-puck model. Basically the robots will act as trees (so they are static) and will have green leds on at the default state. One of them will act as the source of fire turning red and start an internal counter. When the counter reaches a specific value i want to use the range and bearing communication to send a signal to nearby "trees" to catch fire.

My problem is that although i use the range value of the range and bearing sensor, the fire spreads pretty random and after the first "wave" it stops spreading. Am i missing something on how the range is calculated or am i using it wrong?

That's what i use to put a "tree" on fire:

Code: Select all

const CCI_RangeAndBearingSensor::TReadings& tPackets = m_RABS -> GetReadings(); for(size_t i=0; i<tPackets.size(); ++i){ if(tPackets[i].Range < 10){ m_pcLEDs -> SetAllColors(CColor::RED); IsOnFire= true; }
And that's the message i send from a burning "tree":

Code: Select all

if(f_counter>10){ m_RABA -> SetData(0,1); }
Here is the simulation on 1st step (red tree is the one on fire)
Image

And here is after the message is sent (trees caught fire on the left side of the arena)
Image

Thanks :)

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

Re: e-puck range and bearing

Postby pincy » Thu Mar 10, 2016 1:07 am

Hi elriden,

From the code you post it is difficult to understand what is going wrong. To debug your problem, I suggest the following:
  1. Set the show_rays attribute of the range and bearing sensor to true, so you see who is talking to whom;
  2. Consider that, when you set a message with the RAB, that message is sent at every step until you change the message.
If you suspect a bug in ARGoS, send your complete code in a form I can run, and I'll try to understand what is going wrong.

Cheers,
Carlo
I made ARGoS.

elriden
Posts: 2
Joined: Thu Dec 03, 2015 12:10 am

Re: e-puck range and bearing

Postby elriden » Thu Mar 10, 2016 11:30 pm

Thanks for the help! I managed to make it work. Not sure if it's a bug or not but i had to initialize the RAB message for all robots and then it worked! you can see the code below.

Code: Select all

void Cburning_forest::Init(TConfigurationNode& t_node) { m_pcLEDs = GetActuator<CCI_LEDsActuator >("leds"); m_pcProximity = GetSensor <CCI_ProximitySensor >("proximity"); m_RABA = GetActuator<CCI_RangeAndBearingActuator >("range_and_bearing"); m_RABS = GetSensor <CCI_RangeAndBearingSensor >("range_and_bearing"); m_pcLEDs->SetAllColors(CColor::GREEN); std::string robotID ; robotID = this->GetId(); IsOnFire = false; m_RABA -> ClearData(); // <-Added this line to make it work m_RABA -> SetData(0,0); // <-Added this line to make it work if(robotID.compare("fb1")==0){ m_pcLEDs->SetAllColors(CColor::YELLOW); IsOnFire = true; } } void Cburning_forest::ControlStep(){ //TODO add colors for burning states if(IsOnFire){ if (f_counter > 100){ m_pcLEDs->SetAllColors(CColor::BLACK); IsOnFire=false; } else if(f_counter > 25){ m_pcLEDs->SetAllColors(CColor::RED); } //TODO Send burning signal m_RABA -> ClearData(); if(f_counter == 25){ m_RABA -> SetData(0,1); } ++f_counter; } else{ const CCI_RangeAndBearingSensor::TReadings& tPackets = m_RABS -> GetReadings(); for(size_t i=0; i<tPackets.size(); ++i){ if(tPackets[i].Range < 100 && tPackets[i].Data[0] == 1) { //process only messages from trees on fire m_pcLEDs -> SetAllColors(CColor::YELLOW); IsOnFire= true; } } } }


Return to “How to... ?”