robocomp/dsr-graph

Error using dsr_api::insert_node()

Closed this issue · 4 comments

I was trying to insert a new node in G using dsr_api::insert_node() in graspDSR component :

// define object node
Node object = Node();
object.type("mesh");
object.name(objectname);
object.agent_id(17);
object.id(id);

// inject object node into graph
auto id = G->insert_node(object);

However, I always get Cannot connect to idserver. Aborting error.

I think the second one is the problem,
As I'm sure that idserver is running fine and, also, I use the default constructor of G.

So, the solution to this issue is to include DSRGetID interface in graspDSR, like so :

import "ObjectPoseEstimationRGBD.idsl";
import "DSRGetID.idsl";

Component graspDSR
{
    Communications
    {
        requires ObjectPoseEstimationRGBD, DSRGetID;
    };
    language Cpp11;
    gui Qt(QMainWindow);
    options dsr;
};

Then, initialize G with DSRGetID proxy, like so :

G = std::make_shared<DSR::DSRGraph>(0, agent_name, agent_id, "", dsrgetid_proxy); // Init nodes

DSRGetID is an interface implemented by idserver agent and responsible for obtaining node ids in the graph.

I have changed the robocompdsl code to automatically add the DSRGetID require and import whenever the options dsr is added.
I have also modified the DSRGraph constructor to include the dsrgetid_proxy.
Thank you for your contribution @DarkGeekMS.