Skip to content

What are the requirements for MapCollection / MapNode? #396

Open
@adeilsonsilva

Description

@adeilsonsilva

Recently I tried to use MapCollection class, but it seemed to me that this class and its derivatives are still in a early stage, with many TODOs and methods to be improved. I think I was able to understand some of the internal structure but it wasn't clear how to contribute for these classes specifically.

One minor example is that the write method in MapCollection iterate its nodes to create separate files for them. The problem is it tries to append the filename (node id) to the path in a wrong order, creating an invalid filename and thus making writeMap crash.

    std::ofstream outfile(filename.c_str());
    outfile << "#This file was generated by the write-method of MapCollection\n";

    for(typename std::vector<MAPNODE* >::iterator it = nodes.begin(); it != nodes.end(); ++it){
      std::string id = (*it)->getId();
      pose6d origin = (*it)->getOrigin();
      std::string nodemapFilename = "nodemap_";
      nodemapFilename.append(id);
      nodemapFilename.append(".bt");

      outfile << "MAPNODEID " << id << "\n";
      outfile << "MAPNODEFILENAME "<< nodemapFilename << "\n";
      outfile << "MAPNODEPOSE " << origin.x() << " " << origin.y() << " " << origin.z() << " "
              << origin.roll() << " " << origin.pitch() << " " << origin.yaw() << std::endl;
      ok = ok && (*it)->writeMap(nodemapFilename);
    }

Another thing that comes to mind is that MapCollection stores the node as a vector of pointers, leaving memory management to the user:

  protected:

    std::vector<MAPNODE*> nodes;

which may lead to some memory corruption problems (if the user intantiates MAPNODE with new but frees it incorrectly, for example). Maybe it could manage that memory internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions