23 #include <mars/data_broker/DataBrokerInterface.h> 25 #include <mars/interfaces/sim/EntityManagerInterface.h> 26 #include <mars/interfaces/sim/SimulatorInterface.h> 27 #include <mars/interfaces/sim/NodeManagerInterface.h> 28 #include <mars/interfaces/sim/JointManagerInterface.h> 29 #include <mars/interfaces/sim/SensorManagerInterface.h> 30 #include <mars/interfaces/sim/MotorManagerInterface.h> 31 #include <mars/interfaces/sim/ControllerManagerInterface.h> 32 #include <mars/interfaces/graphics/GraphicsManagerInterface.h> 33 #include <mars/sim/SimEntity.h> 34 #include <mars/sim/SimMotor.h> 35 #include <mars/entity_generation/entity_factory/EntityFactoryManager.h> 36 #include <mars/interfaces/Logging.hpp> 38 #include <mars/utils/misc.h> 39 #include <mars/utils/mathUtils.h> 40 #include <smurf_parser/SMURFParser.h> 61 using namespace interfaces;
62 using namespace utils;
66 entity_generation::EntityFactoryInterface(
"smurf, urdf") {
69 "mars_entity_factory");
132 if (map->find(
"URI") != map->end()) {
133 std::string file = (*map)[
"URI"];
134 if (!file.empty() && file[0] !=
'/') {
139 if (map->find(
"URIs") != map->end()) {
140 ConfigVector::iterator vIt = (*map)[
"URIs"].begin();
141 for (; vIt != (*map)[
"URIs"].end(); ++vIt) {
142 std::string file = (std::string) (*vIt);
143 if (!file.empty() && file[0] !=
'/') {
152 ConfigVector::iterator it;
155 if (map->find(
"link") != map->end()) {
156 (*map)[
"nodeID"] =
nodeIDMap[(*map)[
"link"]];
158 if (map->find(
"joint") != map->end()) {
159 (*map)[
"jointID"] =
jointIDMap[(*map)[
"joint"]];
161 if (map->find(
"links") != map->end()) {
162 for (it = (*map)[
"links"].begin(); it != (*map)[
"links"].end(); ++it) {
166 if (map->find(
"collisions") != map->end()) {
167 for (it = (*map)[
"collisions"].begin();
168 it != (*map)[
"collisions"].end(); ++it) {
172 if (map->find(
"joints") != map->end()) {
173 for (it = (*map)[
"joints"].begin(); it != (*map)[
"joints"].end(); ++it) {
177 if (map->find(
"motors") != map->end()) {
178 for (it = (*map)[
"motors"].begin(); it != (*map)[
"motors"].end(); ++it) {
189 std::string filename = (std::string)
entityconfig[
"file"];
190 fprintf(stderr,
"SMURF::createEntity: Creating entity of type %s\n", ((std::string)
entityconfig[
"type"]).c_str());
191 if((std::string)entityconfig[
"type"] ==
"smurf" || entityconfig[
"type"].getString() ==
"particle") {
192 model = smurf_parser::parseFile(&entityconfig, path, filename,
true);
193 #ifdef DEBUG_SCENE_MAP 201 if (entityconfig.find(
"parent") != entityconfig.end())
202 if ((std::string)entityconfig[
"parent"] ==
"world")
207 #ifdef DEBUG_SCENE_MAP 208 entityconfig.toYamlFile(
"entityconfig.yml");
210 for (it = entityconfig.begin(); it != entityconfig.end(); ++it) {
211 fprintf(stderr,
" ...loading smurf data section %s.\n", it->first.c_str());
213 tmpconfig[it->first] = it->second;
217 std::string urdfpath = path + filename;
218 fprintf(stderr,
" ...loading urdf data from %s.\n", urdfpath.c_str());
219 fprintf(stderr,
"parsing model...\n");
226 std::string
robotname = (std::string)entityconfig[
"name"];
228 robotname =
"unknown_robot";
237 fprintf(stderr,
"mapIndex: %d\n",
mapIndex);
245 ConfigVector::iterator it;
246 for (it = config[
"motors"].begin(); it != config[
"motors"].end(); ++it) {
251 (*it)[
"jointIndex"] =
jointIDMap[(*it)[
"joint"]];
253 #ifdef DEBUG_SCENE_MAP 257 std::map<std::string, unsigned long> * idmap;
258 std::map<std::string, std::string> *namemap;
259 for (it = config[
"sensors"].begin(); it != config[
"sensors"].end(); ++it) {
262 tmpmap[
"attached_node"] = (
unsigned long)
nodeIDMap[(std::string) tmpmap[
"link"]];
264 if ((std::string) tmpmap[
"type"] ==
"Joint6DOF") {
265 std::string linkname = (std::string) tmpmap[
"link"];
266 fprintf(stderr,
"addConfig: %s\n", linkname.c_str());
267 std::string jointname =
model->getLink(linkname)->parent_joint->name;
268 fprintf(stderr,
"addConfig: %s\n", jointname.c_str());
272 std::vector<ConfigMap>::iterator it =
jointList.begin();
274 if((
NodeId)(*it)[
"index"] == (
NodeId)tmpmap[
"jointID"]) {
275 (*it)[
"reducedDataPackage"] =
false;
279 fprintf(stderr,
"creating Joint6DOF..., %lu, %lu\n", (
unsigned long) tmpmap[
"nodeID"],
280 (
unsigned long) tmpmap[
"jointID"]);
284 if (tmpmap.find(
"id") != tmpmap.end()) {
286 if (((std::string) tmpmap[
"type"]).find(
"Joint") != std::string::npos) {
289 if (((std::string) tmpmap[
"type"]).find(
"Node") != std::string::npos) {
291 if (((std::string) tmpmap[
"type"]).find(
"Contact") != std::string::npos)
294 if (((std::string) tmpmap[
"type"]).find(
"Motor") != std::string::npos) {
297 for (ConfigVector::iterator idit = tmpmap[
"id"].begin();
298 idit != tmpmap[
"id"].end(); ++idit) {
302 tmpids.
append(
ConfigAtom((
unsigned long) (*idmap)[(*namemap)[(std::string) (*idit)]]));
304 tmpids +=
ConfigAtom((
unsigned long) (*idmap)[(std::string) (*idit)]);
307 fprintf(stderr,
"Found sensor with id list, but of no known category.\n");
310 tmpmap[
"id"] = tmpids;
316 #ifdef DEBUG_SCENE_MAP 320 for (it = config[
"materials"].begin(); it != config[
"materials"].end(); ++it) {
322 std::vector<ConfigMap>::iterator mIt =
materialList.begin();
324 if ((std::string) (*mIt)[
"name"] == (std::string) (*it)[
"name"]) {
330 for (it = config[
"nodes"].begin(); it != config[
"nodes"].end(); ++it) {
332 std::vector<ConfigMap>::iterator nIt =
nodeList.begin();
333 for (; nIt !=
nodeList.end(); ++nIt) {
334 if ((std::string) (*nIt)[
"name"] == (std::string) (*it)[
"name"]) {
336 for (; cIt != it->endMap(); ++cIt) {
337 (*nIt)[cIt->first] = cIt->second;
343 for (it = config[
"joint"].begin(); it != config[
"joint"].end(); ++it) {
345 std::vector<ConfigMap>::iterator nIt =
jointList.begin();
347 if ((std::string) (*nIt)[
"name"] == (std::string) (*it)[
"name"]) {
349 for (; cIt != it->endMap(); ++cIt) {
350 (*nIt)[cIt->first] = cIt->second;
357 for (it = config[
"visuals"].begin(); it != config[
"visuals"].end(); ++it) {
359 std::string cmpName = (std::string) (*it)[
"name"];
360 std::vector<ConfigMap>::iterator nIt =
nodeList.begin();
363 for (; nIt !=
nodeList.end(); ++nIt) {
364 if ((std::string) (*nIt)[
"name"] == cmpName) {
366 for (; cIt != it->endMap(); ++cIt) {
367 if (cIt->first !=
"name") {
368 (*nIt)[cIt->first] = cIt->second;
376 fprintf(stderr,
"visual: couldn't find %s\n", cmpName.c_str());
379 for (it = config[
"collision"].begin(); it != config[
"collision"].end(); ++it) {
381 std::string cmpName = (std::string) (*it)[
"name"];
382 std::vector<ConfigMap>::iterator nIt =
nodeList.begin();
385 for (; nIt !=
nodeList.end(); ++nIt) {
386 if ((std::string) (*nIt)[
"name"] == cmpName) {
388 for (; cIt != it->endMap(); ++cIt) {
389 if (cIt->first !=
"name") {
390 if (cIt->first ==
"bitmask") {
391 (*nIt)[
"coll_bitmask"] = (int) cIt->second;
393 (*nIt)[cIt->first] = cIt->second;
403 for (it = config[
"lights"].begin(); it != config[
"lights"].end(); ++it) {
406 #ifdef DEBUG_SCENE_MAP 410 for (it = config[
"graphics"].begin(); it != config[
"graphics"].end(); ++it) {
413 #ifdef DEBUG_SCENE_MAP 417 for (it = config[
"controllers"].begin(); it != config[
"controllers"].end(); ++it) {
421 ConfigVector::iterator it2;
422 if (it->hasKey(
"sensors")) {
423 for (it2 = (*it)[
"sensors"].begin(); it2 != (*it)[
"sensors"].end(); ++it2) {
424 (*it)[
"sensorid"].push_back(
sensorIDMap[(std::string) *it2]);
427 if (it->hasKey(
"motors")) {
428 for (it2 = (*it)[
"motors"].begin(); it2 != (*it)[
"motors"].end(); ++it2) {
429 (*it)[
"motorid"] +=
motorIDMap[(std::string) *it2];
433 #ifdef DEBUG_SCENE_MAP 441 urdf::Pose pose_ = pose;
442 urdf::Pose toPose_ = toPose;
447 toPose_.position.x *= -1;
448 toPose_.position.y *= -1;
449 toPose_.position.z *= -1;
450 p = pose_.position + toPose_.position;
451 p = toPose_.rotation.GetInverse() * p;
452 r = (toPose_.rotation.GetInverse() * pose_.rotation);
453 *v =
Vector(p.x, p.y, p.z);
458 *v =
Vector(pose.position.x, pose.position.y, pose.position.z);
466 double epsilon = 0.00000000001;
467 if (fabs(p1.position.x - p2.position.x) > epsilon)
469 if (fabs(p1.position.y - p2.position.y) > epsilon)
471 if (fabs(p1.position.z - p2.position.z) > epsilon)
473 if (fabs(p1.rotation.x - p2.rotation.x) > epsilon)
475 if (fabs(p1.rotation.y - p2.rotation.y) > epsilon)
477 if (fabs(p1.rotation.z - p2.rotation.z) > epsilon)
479 if (fabs(p1.rotation.w - p2.rotation.w) > epsilon)
486 double epsilon = 0.0000000001;
487 if (p.position.x > epsilon || p.position.x < -epsilon)
489 if (p.position.y > epsilon || p.position.y < -epsilon)
491 if (p.position.z > epsilon || p.position.z < -epsilon)
493 if (p.rotation.x > epsilon || p.position.x < -epsilon)
495 if (p.rotation.y > epsilon || p.position.y < -epsilon)
497 if (p.rotation.z > epsilon || p.position.z < -epsilon)
499 if (p.rotation.w > 1 + epsilon || p.rotation.w < 1 - epsilon)
508 config[
"name"] =
"_emptyVisualMaterial";
509 config[
"exists"] =
true;
510 config[
"diffuseFront"][
"a"] = 1.0;
511 config[
"diffuseFront"][
"r"] = 1.0;
512 config[
"diffuseFront"][
"g"] = 0.0;
513 config[
"diffuseFront"][
"b"] = 0.0;
514 config[
"texturename"] =
"";
516 #ifdef DEBUG_SCENE_MAP 526 config[
"name"] =
"_originMaterial";
527 config[
"exists"] =
true;
528 config[
"diffuseFront"][
"a"] = 1.0;
529 config[
"diffuseFront"][
"r"] = 0.0;
530 config[
"diffuseFront"][
"g"] = 0.0;
531 config[
"diffuseFront"][
"b"] = 1.0;
532 config[
"texturename"] =
"";
533 config[
"cullMask"] = 0;
534 #ifdef DEBUG_SCENE_MAP 542 (*map)[
"origname"] =
"";
543 (*map)[
"materialName"] =
"_emptyVisualMaterial";
544 (*map)[
"visualType"] =
"empty";
548 Vector size(0.01, 0.01, 0.01);
549 (*map)[
"physicmode"] =
"box";
550 (*map)[
"coll_bitmask"] = 0;
557 if (link->name.empty()) {
562 if (link->parent_joint) {
563 config[
"relativeid"] =
linkIDMap[link->parent_joint->parent_link_name];
565 config[
"relativeid"] = (
unsigned long) 0;
569 config[
"name"] = name;
575 config[
"movable"] = !fixed;
581 if (link->parent_joint)
582 pose = link->parent_joint->parent_to_joint_origin_transform;
591 config[
"origname"] =
"sphere";
592 config[
"material"] =
"_originMaterial";
594 #ifdef DEBUG_SCENE_MAP 603 if (link->name.empty()) {
606 name =
"inertial_" + link->name;
610 config[
"name"] = name;
614 config[
"movable"] =
true;
618 config[
"noDataPackage"] =
true;
622 config[
"density"] = 0.0;
623 config[
"mass"] = link->inertial->mass;
624 config[
"inertia"] =
true;
625 config[
"i00"] = link->inertial->ixx;
626 config[
"i01"] = link->inertial->ixy;
627 config[
"i02"] = link->inertial->ixz;
628 config[
"i10"] = link->inertial->ixy;
629 config[
"i11"] = link->inertial->iyy;
630 config[
"i12"] = link->inertial->iyz;
631 config[
"i20"] = link->inertial->ixz;
632 config[
"i21"] = link->inertial->iyz;
633 config[
"i22"] = link->inertial->izz;
639 pose = link->inertial->origin;
648 #ifdef DEBUG_SCENE_MAP 657 if (collision->name.empty()) {
660 name = collision->name;
664 config[
"name"] = name;
668 config[
"movable"] = !fixed;
670 config[
"mass"] = 0.001;
671 config[
"density"] = 0.0;
674 urdf::GeometrySharedPtr tmpGeometry = collision->geometry;
675 Vector size(0.0, 0.0, 0.0);
676 Vector scale(1.0, 1.0, 1.0);
678 switch (tmpGeometry->type) {
679 case urdf::Geometry::SPHERE:
680 size.x() = ((urdf::Sphere*) tmpGeometry.get())->radius;
681 config[
"physicmode"] =
"sphere";
683 case urdf::Geometry::BOX:
684 tmpV = ((urdf::Box*) tmpGeometry.get())->dim;
685 size =
Vector(tmpV.x, tmpV.y, tmpV.z);
686 config[
"physicmode"] =
"box";
688 case urdf::Geometry::CYLINDER:
689 size.x() = ((urdf::Cylinder*) tmpGeometry.get())->radius;
690 size.y() = ((urdf::Cylinder*) tmpGeometry.get())->length;
691 config[
"physicmode"] =
"cylinder";
693 case urdf::Geometry::MESH:
694 tmpV = ((urdf::Mesh*) tmpGeometry.get())->scale;
695 scale =
Vector(tmpV.x, tmpV.y, tmpV.z);
697 config[
"filename"] = ((urdf::Mesh*) tmpGeometry.get())->filename;
698 config[
"origname"] =
"";
699 config[
"physicmode"] =
"mesh";
700 config[
"loadSizeFromMesh"] =
true;
703 config[
"physicmode"] =
"undefined";
721 #ifdef DEBUG_SCENE_MAP 730 if (visual->name.empty()) {
737 config[
"name"] = name;
741 config[
"movable"] = !fixed;
743 config[
"mass"] = 0.001;
744 config[
"density"] = 0.0;
745 Vector v(0.001, 0.001, 0.001);
755 urdf::GeometrySharedPtr tmpGeometry = visual->geometry;
756 Vector size(0.0, 0.0, 0.0);
757 Vector scale(1.0, 1.0, 1.0);
759 config[
"filename"] =
"PRIMITIVE";
760 switch (tmpGeometry->type) {
761 case urdf::Geometry::SPHERE:
762 size.x() = 2.0*((urdf::Sphere*) tmpGeometry.get())->radius;
763 size.y() = 2.0*((urdf::Sphere*) tmpGeometry.get())->radius;
764 size.z() = 2.0*((urdf::Sphere*) tmpGeometry.get())->radius;
765 config[
"origname"] =
"sphere";
767 case urdf::Geometry::BOX:
768 tmpV = ((urdf::Box*) tmpGeometry.get())->dim;
769 size =
Vector(tmpV.x, tmpV.y, tmpV.z);
770 config[
"origname"] =
"box";
772 case urdf::Geometry::CYLINDER:
773 size.x() = 2.0*((urdf::Cylinder*) tmpGeometry.get())->radius;
774 size.y() = 2.0*((urdf::Cylinder*) tmpGeometry.get())->radius;
775 size.z() = ((urdf::Cylinder*) tmpGeometry.get())->length;
776 config[
"origname"] =
"cylinder";
778 case urdf::Geometry::MESH:
779 tmpV = ((urdf::Mesh*) tmpGeometry.get())->scale;
780 scale =
Vector(tmpV.x, tmpV.y, tmpV.z);
781 config[
"filename"] = ((urdf::Mesh*) tmpGeometry.get())->filename;
782 config[
"origname"] =
"";
789 config[
"materialName"] = visual->material_name;
793 config[
"noPhysical"] =
true;
794 config[
"noDataPackage"] =
true;
798 #ifdef DEBUG_SCENE_MAP 812 if (link->parent_joint)
816 if (link->inertial && !fixed) {
821 if (link->collision) {
822 for (std::vector<urdf::CollisionSharedPtr >::iterator it = link->collision_array.begin();
823 it != link->collision_array.end(); ++it) {
830 for (std::vector<urdf::VisualSharedPtr >::iterator it = link->visual_array.begin();
831 it != link->visual_array.end(); ++it) {
836 for (std::vector<urdf::LinkSharedPtr >::iterator it = link->child_links.begin();
837 it != link->child_links.end(); ++it) {
838 fprintf(stderr,
"parsing link %s->%s..\n", (link->name).c_str(), ((*it)->name).c_str());
846 urdf::JointSharedPtr joint = childlink->parent_joint;
847 config[
"name"] = joint->name;
850 config[
"nodeindex1"] =
nodeIDMap[joint->parent_link_name];
851 config[
"nodeindex2"] =
nodeIDMap[joint->child_link_name];
852 config[
"anchorpos"] =
"node2";
862 if (joint->type == urdf::Joint::REVOLUTE
863 || joint->type == urdf::Joint::CONTINUOUS) {
864 config[
"type"] =
"hinge";
865 }
else if (joint->type == urdf::Joint::PRISMATIC) {
866 config[
"type"] =
"slider";
867 }
else if (joint->type == urdf::Joint::FIXED) {
868 config[
"type"] =
"fixed";
871 config[
"type"] =
"fixed";
878 axispose.position = pose.rotation * joint->axis;
880 v =
Vector(axispose.position.x, axispose.position.y, axispose.position.z);
884 #ifdef DEBUG_SCENE_MAP 888 config[
"reducedDataPackage"] =
true;
893 urdf::Pose globalPose;
894 urdf::LinkSharedPtr pLink = link->getParent();
895 if (link->parent_joint) {
896 globalPose = link->parent_joint->parent_to_joint_origin_transform;
900 globalPose.position = parentPose.rotation * globalPose.position;
901 globalPose.position = globalPose.position + parentPose.position;
902 globalPose.rotation = parentPose.rotation * globalPose.rotation;
911 config[
"name"] = material->name;
912 config[
"exists"] =
true;
913 config[
"diffuseFront"][
"a"] = (double) material->color.a;
914 config[
"diffuseFront"][
"r"] = (
double) material->color.r;
915 config[
"diffuseFront"][
"g"] = (double) material->color.g;
916 config[
"diffuseFront"][
"b"] = (
double) material->color.b;
917 config[
"texturename"] = material->texture_filename;
920 #ifdef DEBUG_SCENE_MAP 928 fprintf(stderr,
"ERROR: SMURF:parseURDF no such file: %s\n",
932 model = urdf::parseURDFFile(filename);
947 std::map<std::string, urdf::MaterialSharedPtr >::iterator it;
948 for (it =
model->materials_.begin(); it !=
model->materials_.end(); ++it) {
956 fprintf(stderr,
"smurfing robot: %s...\n",
robotname.c_str());
957 #ifdef DEBUG_SCENE_MAP 963 for (
unsigned int i = 0; i <
nodeList.size(); ++i)
965 fprintf(stderr,
"Couldn't load node %lu, %s..\n'", (
unsigned long)
nodeList[i][
"index"], ((std::string)
nodeList[i][
"name"]).c_str());
970 for (
unsigned int i = 0; i <
jointList.size(); ++i)
974 for (
unsigned int i = 0; i <
motorList.size(); ++i)
980 for (
unsigned int i = 0; i <
sensorList.size(); ++i)
988 for (
unsigned int i = 0; i <
lightList.size(); ++i)
992 for (
unsigned int i = 0; i <
graphicList.size(); ++i)
998 map[
"rootNode"] =
model->root_link_->name;
1010 string suffix, tmpfilename;
1013 tmpfilename =
trim(config.
get(
"filename", tmpfilename));
1015 if (!tmpfilename.empty()) {
1017 if (suffix ==
".obj" || suffix ==
".OBJ") {
1020 tmpfilename.append(
".bobj");
1021 string tmpfilename2 = tmpfilename;
1025 fprintf(stderr,
"Loading .bobj instead of .obj for file: %s\n", tmpfilename.c_str());
1026 config[
"filename"] = tmpfilename2;
1030 int index = tmpfilename2.find(
"obj/");
1031 if (index != string::npos) {
1032 string newfilename =
replaceString(tmpfilename2,
"obj/",
"bobj/");
1033 string tmpfilename2 = newfilename;
1036 fprintf(stderr,
"Loading .bobj instead of .obj for file: %s\n", newfilename.c_str());
1037 config[
"filename"] = tmpfilename2;
1048 if ((std::string) config[
"materialName"] != std::string(
"")) {
1049 std::map<std::string, MaterialData>::iterator it;
1060 if (suffix ==
".stl" || suffix ==
".STL") {
1069 #ifdef DEBUG_SCENE_MAP 1096 fprintf(stderr,
"SMURF: error while smurfing joint\n");
1118 fprintf(stderr,
"SMURF: error while smurfing motor\n");
1151 fprintf(stderr,
"SMURF: error while smurfing graphic\n");
1166 fprintf(stderr,
"SMURF: error while smurfing light\n");
1179 fprintf(stderr,
"SMURF: error while smurfing Controller\n");
1186 LOG_ERROR(
"SMURF: addController returned 0");
MotorData is a struct to exchange motor information between the GUI and the simulation.
NodeManagerInterface * nodes
std::map< std::string, std::string > collisionNameMap
LightData is a struct to exchange light information between the Dialog_Add_Light, the MainWindow and ...
std::map< std::string, unsigned long > jointIDMap
unsigned long nextGroupID
JointData is a class to exchange joint information between the simulation modules.
void createVisual(const urdf::VisualSharedPtr &visual, bool fixed)
configmaps::ConfigMap debugMap
void appendConfig(const configmaps::ConfigMap ¶meters)
GraphicsManagerInterface * graphics
std::string getFilenameSuffix(const std::string &file)
given a filename "foobar.baz" this will return ".baz"
bool isNullPos(const urdf::Pose &p)
unsigned int getMappedSceneByName(const std::string &scenename) const
unsigned int loadMaterial(configmaps::ConfigMap config)
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
std::vector< configmaps::ConfigMap > motorList
void getSensorIDList(configmaps::ConfigMap *map)
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix)
SensorManagerInterface * sensors
void createInertial(const urdf::LinkSharedPtr &link)
MotorManagerInterface * motors
std::string trim(const std::string &str)
remove leading and trailing whitespaces
unsigned int setMappedID(unsigned long id_old, unsigned long id_new, unsigned int indextype, unsigned int source)
virtual unsigned long getMaxGroupID()=0
NodeData is a struct to exchange node information between the GUI and the simulation.
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
void toYamlFile(const std::string &filename) const
ControllerManagerInterface * controllers
virtual unsigned long addJoint(JointData *jointS, bool reload=false)=0
Add a joint to the joint pool of the simulation.
std::string filename
The filename of the node to load the visual representation from.
unsigned int loadController(configmaps::ConfigMap config)
std::vector< configmaps::ConfigMap > graphicList
unsigned int loadMotor(configmaps::ConfigMap config)
std::map< std::string, unsigned long > motorIDMap
MaterialData is a struct to exchange material information of nodes.
unsigned int loadNode(configmaps::ConfigMap config)
SMURF(lib_manager::LibManager *theManager)
virtual void switchPluginUpdateMode(int mode, PluginInterface *pl)=0
void vectorToConfigItem(ConfigItem *item, Vector *v)
static ConfigMap fromYamlFile(const std::string &filename, bool loadURI=false)
virtual NodeId addNode(NodeData *nodeS, bool reload=false, bool loadGraphics=true)=0
Add a node to the node pool of the simulation.
virtual BaseSensor * createAndAddSensor(configmaps::ConfigMap *config, bool reload=true)=0
Adds an sensor to the known sensors list.
void addMotor(unsigned long motorId, const std::string &name)
std::list< FIFOItem< std::string, ConfigItem > >::iterator iterator
utils::Quaternion visual_offset_rot
In the same way as the visual_offset_pos, this quaternion can be used to differentiate the orientatio...
void createOriginMaterial()
std::map< std::string, interfaces::MaterialData > materialMap
void poseToVectorAndQuaternion(const urdf::Pose &pose, utils::Vector *v, utils::Quaternion *q)
Quaternion quaternionFromMembers(T q)
Quaternion eulerToQuaternion(const Vector &euler_v)
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
std::map< std::string, unsigned long > nodeIDMap
virtual void registerFactory(const std::string type, EntityFactoryInterface *factory)
interfaces::BaseSensor * loadSensor(configmaps::ConfigMap config)
std::vector< configmaps::ConfigMap > jointList
void handleURIs(configmaps::ConfigMap *map)
void translateJoint(urdf::LinkSharedPtr childlink)
utils::Color diffuseFront
void setMappedSceneName(const std::string &scenename)
void createModel(bool fixed)
unsigned long getID() const
unsigned int loadGraphic(configmaps::ConfigMap config)
std::vector< configmaps::ConfigMap > lightList
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
DESTROY_LIB(mars::smurf::SMURF)
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
std::vector< configmaps::ConfigMap > sensorList
unsigned long nextMaterialID
void createCollision(const urdf::CollisionSharedPtr &collision, bool fixed)
T * acquireLibraryAs(const std::string &libName, bool load=false)
std::vector< configmaps::ConfigMap > controllerList
void createOrigin(const urdf::LinkSharedPtr &link, bool fixed)
void quaternionToConfigItem(ConfigItem *item, Quaternion *q)
Copyright 2012, DFKI GmbH Robotics Innovation Center.
void addEmptyVisualToNode(configmaps::ConfigMap *map)
void translateLink(urdf::LinkSharedPtr link, bool fixed)
JointManagerInterface * joints
virtual unsigned long addMotor(MotorData *motorS, bool reload=false)=0
Add a motor to the simulation.
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vector
Eigen::Quaternion< double, Eigen::DontAlign > Quaternion
CREATE_LIB(mars::smurf::SMURF)
unsigned long nextMotorID
std::map< std::string, std::string > visualNameMap
void createEmptyVisualMaterial()
unsigned long nextControllerID
void handleURI(configmaps::ConfigMap *map, std::string uri)
void removeFilenameSuffix(std::string *file)
given a filename "foobar.baz" this will remove the extension (including the dot ".") resulting in "foobar".
unsigned long nextSensorID
bool pathExists(const std::string &path)
check whether a file or directory exists.
virtual unsigned long addController(const ControllerData &controllerData)=0
Add a controller to the simulation.
void addJoint(long unsigned int jointId, const std::string &name)
std::string getRobotname()
unsigned int loadLight(configmaps::ConfigMap config)
std::vector< configmaps::ConfigMap > nodeList
void addNode(unsigned long nodeId, const std::string &name)
void addConfigMap(configmaps::ConfigMap &config)
bool isEqualPos(const urdf::Pose &p1, const urdf::Pose p2)
std::string name
The name of the node.
virtual sim::SimEntity * createEntity(const configmaps::ConfigMap &config)
virtual void addLight(LightData light)=0
urdf::Pose getGlobalPose(const urdf::LinkSharedPtr &link)
virtual void setGraphicOptions(const GraphicData &options, bool ignoreClearColor=false)=0
MaterialData material
The material struct defines the visual material of the node.
unsigned int loadJoint(configmaps::ConfigMap config)
bool fromConfigMap(configmaps::ConfigMap *config, std::string filenamePrefix, LoadCenter *loadCenter=0)
virtual void connectMimics()=0
void update(mars::interfaces::sReal time_ms)
std::map< std::string, unsigned long > linkIDMap
std::string replaceString(const std::string &source, const std::string &s1, const std::string &s2)
void addEmptyCollisionToNode(configmaps::ConfigMap *map)
configmaps::ConfigMap entityconfig
unsigned long nextJointID
virtual void printNodeMasses(bool onlysum)=0
size_t append(const ConfigItem &item)
unsigned long index
The unique index of the node.
void addController(unsigned long controllerId)
unsigned int parseURDF(std::string filename)
void convertPose(const urdf::Pose &pose, const urdf::Pose &toPose, utils::Vector *v, utils::Quaternion *q)
T get(const std::string &key, const T &defaultValue)
unsigned long currentNodeID
urdf::ModelInterfaceSharedPtr model
void handleFilenamePrefix(std::string *file, const std::string &prefix)
ErrorNumber releaseLibrary(const std::string &libName)
Releases a previously acquired library.
std::map< std::string, unsigned long > sensorIDMap
void setInitialPose(bool reset=false)
void createMaterial(const urdf::MaterialSharedPtr material)
std::vector< configmaps::ConfigMap > materialList