示例#1
0
bool MapGrid2D::write(yarp::os::ConnectionWriter& connection)
{
    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(9);
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(m_width);
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(m_height);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.x);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.y);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.theta);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_resolution);
    connection.appendInt(BOTTLE_TAG_STRING);
    connection.appendRawString(m_map_name.c_str());

    unsigned char *mem = nullptr;
    int            memsize = 0;
    mem     = m_map_occupancy.getRawImage();
    memsize = m_map_occupancy.getRawImageSize();
    connection.appendInt(BOTTLE_TAG_BLOB);
    connection.appendInt(memsize);
    connection.appendExternalBlock((char*)mem, memsize);
    mem     = m_map_flags.getRawImage();
    memsize = m_map_flags.getRawImageSize();
    connection.appendInt(BOTTLE_TAG_BLOB);
    connection.appendInt(memsize);
    connection.appendExternalBlock((char*)mem, memsize);

    connection.convertTextMode();
    return !connection.isError();
}
示例#2
0
bool VectorBase::write(yarp::os::ConnectionWriter& connection) {
    VectorPortContentHeader header;

    //header.totalLen = sizeof(header)+sizeof(double)*this->size();
    header.listTag = (BOTTLE_TAG_LIST | getBottleTag());
    header.listLen = (int)getListSize();

    connection.appendBlock((char*)&header, sizeof(header));
    const char *ptr = getMemoryBlock();
    int elemSize=getElementSize();
    yAssert(ptr != nullptr);

    connection.appendExternalBlock(ptr, elemSize*header.listLen);

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return !connection.isError();
}
示例#3
0
bool Image::write(yarp::os::ConnectionWriter& connection) {
    ImageNetworkHeader header;
    header.setFromImage(*this);
    /*
    header.listTag = BOTTLE_TAG_LIST;
    header.listLen = 4;
    header.paramNameTag = BOTTLE_TAG_VOCAB;
    header.paramName = VOCAB3('m','a','t');
    header.paramIdTag = BOTTLE_TAG_VOCAB;
    header.id = getPixelCode();
    header.paramListTag = BOTTLE_TAG_LIST + BOTTLE_TAG_INT;
    header.paramListLen = 5;
    header.depth = getPixelSize();
    header.imgSize = getRawImageSize();
    header.quantum = getQuantum();
    header.width = width();
    header.height = height();
    header.paramBlobTag = BOTTLE_TAG_BLOB;
    header.paramBlobLen = getRawImageSize();
    */

    connection.appendBlock((char*)&header,sizeof(header));
    unsigned char *mem = getRawImage();
    if (header.width!=0&&header.height!=0) {
        yAssert(mem!=NULL);

        // Note use of external block.
        // Implies care needed about ownership.
        connection.appendExternalBlock((char *)mem,header.imgSize);
    }

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return !connection.isError();
}