I want to create multiple boxes at random locations each of which has a LED on top. The boxes are foods and will be removed later from the simulation.
Please provide some samples to do it via loop functions.
Thanks in advance.
Code: Select all
<!-- Check argos3 -q box -->
<distribute>
<position method="uniform" min="-2,-2,0" max="2,2,0" />
<orientation method="uniform" min="0,0,0" max="360,0,0" />
<entity quantity="5" max_trials="100">
<box id="b" size="0.5,0.5,0.5" movable="true">
<leds medium="id_of_led_medium">
<led offset="0,0,1.0" anchor="origin" color="red" />
</leds>
</box>
</entity>
</distribute>
Code: Select all
CMyLoopFunctions::Init(...) {
// Get a reference to the LED medium
//
// The passed id "leds" corresponds to the id of the led_medium in
// the XML file
//
// see https://github.com/ilpincy/argos3/blob/master/src/core/simulator/simulator.h
// see https://github.com/ilpincy/argos3/blob/master/src/plugins/simulator/media/led_medium.h
CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds");
// Add a new box with an LED on top
// see https://github.com/ilpincy/argos3/blob/master/src/plugins/simulator/entities/box_entity.h
CBoxEntity* pcBox = new CBoxEntity("box1", // id
CVector3(1.0, 2.0, 0.0), // position
CQuaternion(), // orientation
true, // movable or not?
CVector3(0.5, 0.5, 0.5), // size
1.0); // mass in kg
// Add LED on top of the box
pcBox->AddLED(CVector3(0.0, 0.0, 1.0), // offset
CColor::RED); // color
// Enable LED management for the box
pcBox->EnableLEDs(cLEDMedium);
// Add the box to the simulation
AddEntity(*pcBox);
}
Code: Select all
CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds");
error: no matching function for call to ‘argos::CSimulator::GetMedium(const char [5])’
CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds");
Code: Select all
CBoxEntity& cBox = ...
cBox.GetEmbodiedEntity().GetOriginAnchor()
I am using ARGoS v3.0.0-beta47.Thank you very much for spending time on this question.
I am getting the following error when using:
Code: Select all
CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds");
error: no matching function for call to ‘argos::CSimulator::GetMedium(const char [5])’
CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds");
Code: Select all
CLEDMedium& cLEDMedium = GetSimulator().GetMedium<CLEDMedium>("leds");