Skip to content

How to dynamically create LEDs detectable by an omnidirectional camera #222

Description

@Legendorik

I'm trying to modify the foraging example and spawn light sources at the food positions in loop function to see them with sensors. However, the camera does not recognize the LEDs that have appeared in the arena. I think the problem here is the medium, but I don't know what else I can do.

So, I started with spawning boxes with leds on food points.

void CForagingLoopFunctions::Init(TConfigurationNode &t_node)
{
      .....
      for (UInt32 i = 0; i < unFoodItems; ++i)
      {
         CLEDMedium &cLEDMedium = GetSimulator().GetMedium<CLEDMedium>("leds");
         m_cFoodPos.push_back(
             CVector2(m_pcRNG->Uniform(m_cForagingArenaSideX),
                      m_pcRNG->Uniform(m_cForagingArenaSideY)));

         std::string food_id = "food_" + std::to_string(i);
         CBoxEntity *pcBox = new CBoxEntity(food_id,                                                 // id
                                            CVector3(m_cFoodPos[i].GetX(), m_cFoodPos[i].GetY(), 0), // position
                                            CQuaternion(),                                           // orientation
                                            false,                                                   // movable or not?
                                            CVector3(0.01, 0.01, 0),                                 // size
                                            1);                                                      // mass in kg

         pcBox->AddLED(CVector3(0, 0, 0), // offset
                       CColor::RED);      // color
         // Enable LED management for the box
         pcBox->EnableLEDs(cLEDMedium);
         // Add the box to the simulation
         AddEntity(*pcBox);
      }
      .....
}

This code spawns boxes (invisible due to zero height and small size) and LEDs, but the camera thinks that all 15 LEDs are spawned in the center (shown in the screenshot).
изображение
From this result, I concluded that the EnableLEDs function was used incorrectly. Although the code was taken from the answers from the Argos forum, I am not sure that the LEDs should be enabled after adding them, not before. So i switched calls

          ...
         // Enable LED management for the box
         pcBox->EnableLEDs(cLEDMedium);
         pcBox->AddLED(CVector3(0, 0, 0), // offset
                       CColor::RED);      // color
         // Add the box to the simulation
         AddEntity(*pcBox);

It has gotten worse, now LEDs are undetectable even in the center. I've tried moving them around and playing with offset, but to no avail.

Camera setup

      <sensors>
      ...
        <colored_blob_omnidirectional_camera implementation="rot_z_only" medium="leds" show_rays="true" />
      </sensors>

Media setup

  <media>
    <range_and_bearing id="rab" />
    <led id="leds" />
  </media>

I also tried to spawn just light sources without boxes, but they are still undetectable by camera

         auto pFoodLight = new CLightEntity(food_id, CVector3(m_cFoodPos[i].GetX(), m_cFoodPos[i].GetY(), 0), CColor::BLUE, 3);
         pFoodLight->SetMedium(cLEDMedium);
         pFoodLight->SetEnabled(true);

         AddEntity(*pFoodLight);

Please, tell me what's wrong

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions