Cannot create more than 6 participants in FastDDS - data-distribution-service

I am working with FastDDS and have an application that will have 10-15 writers or readers. However if I try to create more than 6 total participants, the 7th one hangs on the create_participant() function call. It blocks there indefinitely. I'll put a minimal set of code below. My environment:
Windows 10
Visual Studio 2019
FastDDS 2.6.0 (also have the same issue in 2.5.1) Installed from binaries, not built from source
int count{7};
std::vector<eprosima::fastdds::dds::DomainParticipant*> participants;
for (int i = 0; i < count; ++i) {
std::cout << "Creating Participant " << i << "." << std::endl;
eprosima::fastdds::dds::DomainParticipantQos qos;
participants.push_back(eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(0, qos));
std::cout << "Participant " << i << " created." << std::endl;
}
for (auto& p : participants) {
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(p);
}
And the output is:
Creating Participant 0.
Participant 0 created.
Creating Participant 1.
Participant 1 created.
Creating Participant 2.
Participant 2 created.
Creating Participant 3.
Participant 3 created.
Creating Participant 4.
Participant 4 created.
Creating Participant 5.
Participant 5 created.
Creating Participant 6.
It never completes that last create_participant call. If I switch the number to create to 6, it works.

Related

Is there a way to save the cutting planes from SCIP?

I am working on using SCIP to generate cutting planes for my project. I am doing so using a C++ code directly with default plugins included, modified from scip/examples/MIPsolver/src/cppmain. However the array of cutting planes is not saved. The program will be run using the command
./scipplanes [problem file]
The affected part of my program is shown below:
/*******************
* Problem Presolving *
*******************/
/* Presolve problem */
std::cout << "=============" << std::endl;
std::cout << "Presolve problem" << std::endl;
std::cout << "=============" << std::endl;
SCIP_CALL( SCIPpresolve(scip) ); //Presolve to simplify the problem
SCIP_CALL( SCIPsetRealParam(scip, "limits/time", 60) ); //Limit of solving time in seconds
/*************************
* Obtain cutting planes *
*************************/
std::cout << "=============" << std::endl;
std::cout << "Obtaining cutting planes" << std::endl;
std::cout << "=============" << std::endl;
SCIP_ROW** allcuts; //Because SCIPgetCuts outputs this kind of data (memory address/pointer)
int n_cuts; //For for loop iteration
SCIP_CALL( SCIPsolve(scip) );
allcuts = SCIPgetCuts(scip); /*Documentation says that this outputs the array of cuts currently stored in the separation storage,
in the form of a memory address of pointer of SCIP_ROW** */
std::cout << "allcuts is " << allcuts << std::endl;
n_cuts = SCIPgetNCuts(scip);
std::cout << "n_cuts is " << n_cuts << std::endl;
When I ran my code, I obtain n_cuts = 0, but the table of statistics shows :
time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl.
60.0s| 1 | 0 | 33295 | - | 333M | 0 |1164 | 39k| 39k| 120 | 10 | 19 | 0 | 0.000000e+00 | -- | Inf | unknown
There are 120 cuts. I have double checked by running the SCIP binary and using presolve and optimize with a time limit of 60s. The results are the same when display statistics is used.
I have also tried to iterate through allcuts by doing SCIPprintRow(scip, *allcuts, NULL); , but got a segmentation fault.
Thus, I have no idea why the cutting planes are not saved. Would it be possible to offer me some advice on how to solve this problem? Thank you.
I'm pretty sure that all cuts will be freed after the solve is finished (and in any case, SCIP will remove rows from time to time). If you want all the cuts that were used at any point during the solve, you should write an event handler (with event type SCIP_EVENTTYPE_ROWEVENT) that you can use to print the rows with SCIPprintRow)
There is an example of how to write your own event handler in the examples subdirectory.

Prevent splitting inputs at spaces and automatically using later words for later inputs

I have a Function that outputs a string that it's been given to the console via cout, initializes a new string, writes user input into that string and returns it.
I summarized my problem in this piece of code:
#include <iostream>
std::string GetUserInput(std::string question) {
std::cout << question;
std::string inputedData;
std::cin >> inputedData;
return inputedData;
}
int main()
{
std::string userInput1 = GetUserInput("Your first input: ");
std::string userInput2 = GetUserInput("Your second input: ");
std::string userInput3 = GetUserInput("Your third input: ");
std::cout << userInput1 << std::endl;
std::cout << userInput2 << std::endl;
std::cout << userInput3 << std::endl;
}
This works, als long as the user doesn't input any spaces. For example if the input is:
Joe
Walther
Alex
Then the Output will be as expected:
Your first input: Joe
Your second input: Walther
Your third input: Alex
Joe
Walther
Alex
But if a user tries to input something that has a space in it, the input will be split at every space character and the words that come after the first will automatically be used as inputs that are requested at later points in time. For that reason, the output looks something like this:
Your first input: Joe Smith
Your second input: Your third input: Walther Jones
Joe
Smith
Walther
What do I need to do in order to write a complete input string with spaces into a variable and then have other inputs right after that are completely independent of the first input and each other?

OpenNI2+Nite2 isNew() isLost() methods in Kinect SDK

I recently switched from OpenNI2+Nite2 confuguration to official Kinect SDK for a project. In nite my code goes like this:
const nite::Array<nite::UserData>& users = frame.getUsers();
for (int i=0; i<users.getSize(); i++){
const nite::UserData& user = users[i];
if(user.isNew()){/* do this */}
if(user.isLost()){/* do that */}
else {/* update*/}
However, I couldn't find a method that does the same thing as isNew & isLost in Kinect SDK. I implemented my own method for isNew, but I failed in isLost.
// handle user exit
map<string,Group3D*> g3D_copy = g3D;
for(map<string,Group3D*>::iterator mit = g3D_copy.begin();mit != g3D_copy.end();mit++){
if(mit->second->getType() == "KINECT_SKELETON")
{
string groupID = mit->first;
int countExistance2 = 0;
for (int i = 0; i < NUI_SKELETON_COUNT; i++){
int userID = (int)SkeletonFrame.SkeletonData[i].dwTrackingID;
char buffer [33];
sprintf(buffer,"%lu",SkeletonFrame.SkeletonData[i].dwTrackingID);
string myID2 = buffer;
cout << "groupID " << groupID << endl;
cout << "myID2 " << myID2 << endl;
if(myID2 == groupID){ countExistance2++;}
}
// user lost
if(countExistance2 == 0){
delete g3D[groupID];
g3D.erase(groupID);
cout << "*************deleted*******" << endl;
}
}
}
Basicly, I am trying to erase the dedicated slot to a skeleton in a map called g3D in every update of the skeleton frame if the skeleton is lost.
Any ideas or sharp eyes are appreciated.
Finally I solved the problem by counting the frames which do not have a tracked skeleton. Skeleton data has 6 slots and in some frames its tracking id is not set to NUI_SKELETON_TRACKED.
Thus, If the number of empty skeleton slots exceeds 20 (which means appx 3-4 successive empty frames), I assume the user is lost.
// handle user exit
// The skeleton is not tracked in every successive frame, so use g3DCounts to count the number of frames
map<string,Group3D*> g3D_copy = g3D;
for(map<string,Group3D*>::iterator mit = g3D_copy.begin();mit != g3D_copy.end();mit++){
if(mit->second->getType() == "KINECT_SKELETON")
{
string groupID = mit->first;
for (int i = 0; i < NUI_SKELETON_COUNT; i++){
char buffer [33];
sprintf(buffer,"%lu",SkeletonFrame.SkeletonData[i].dwTrackingID);
string myID2 = buffer;
if(myID2 == groupID){ g3DCounts[groupID] = 0;}
else{ g3DCounts[groupID] += 1;}
}
if(g3DCounts[groupID] > 20){
delete g3D[groupID];
g3D.erase(groupID);
cout << "*************deleted successfully*******" << endl;
}
}
}
Hope it helps others

How do I iterate through all the faces in a CGAL StraightSkeleton_2 / HalfedgeDS?

My goal is to take a polygon, find the straight skeleton, then turn each face into its own polygon.
I'm using the CGAL Create_straight_skeleton_2.cpp example as a starting point. I'm able to have it compute the skeleton and can iterate through the faces:
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly);
for( auto face = iss->faces_begin(); face != iss->faces_end(); ++face ) {
// How do I iterate through the vertexes?
}
But with a HalfedgeDSFace it looks like I can only call halfedge() for a HalfedgeDSHalfedge.
At that point I'm confused how to iterate through the vertexes in the face. Do I just treat it like a circular linked list and follow the next pointer until I get back to face->halfedge()?
Here's my first attempt at treating it like a circular linked list:
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly);
std::cout << "Faces:" << iss->size_of_faces() << std::endl;
for( auto face = iss->faces_begin(); face != iss->faces_end(); ++face ) {
std::cout << "Faces:" << iss->size_of_faces() << std::endl;
std::cout << "----" << std::endl;
do {
std::cout << edge->vertex()->point() << std::endl;
edge = edge->next();
} while (edge != face->halfedge());
}
But that seems to put an empty vertex in each face:
Faces:4
----
197.401 420.778
0 0
166.95 178.812
----
511.699 374.635
0 0
197.401 420.778
----
428.06 122.923
0 0
511.699 374.635
----
166.95 178.812
0 0
428.06 122.923
So the iteration is much as I'd expected:
// Each face
for( auto face = iss->faces_begin(); face != iss->faces_end(); ++face ) {
Ss::Halfedge_const_handle begin = face->halfedge();
Ss::Halfedge_const_handle edge = begin;
// Each vertex
do {
std::cout << edge->vertex()->point() << std::endl;
edge = edge->next();
} while (edge != begin);
}
The reason it wasn't working was the contour polygon I was using had a clockwise orientation. Once I reversed the order of the points I started getting valid data out of the faces.
For reference here's how you'd iterate over the vertexes in the contour:
// Pick a face and use the opposite edge to get on the contour.
Ss::Halfedge_const_handle begin = iss->faces_begin()->halfedge()->opposite();
Ss::Halfedge_const_handle edge = begin;
do {
std::cout << edge->vertex()->point() << std::endl;
// Iterate in the opposite direction.
edge = edge->prev();
} while (edge != begin);

Filestreams reading and writing to text file, then convert to binary in c++

What I am trying to do is fairly elementary however I am having trouble with my project. My project is too large to include everything, so I will just include the two functions that I am writing along with what the txt file looks like. This is in c++.
bookmark.cfg
No Title
0 0 0 0 0 0
No Title
1 1 1 1 1 1
No Title
2 2 2 2 2 2
No Title
3 3 3 3 3 3
No Title
4 4 4 4 4 4
No Title
5 5 5 5 5 5
These are my two functions for writing and reading to the text file and my class's private structure
struct BookMark {
std::string strFilename;
unsigned id;
unsigned bookID;
unsigned chapterNumber;
unsigned pageNumber;
unsigned lineNumber;
unsigned columnNumber;
}; // BookMark
// ----------------------------------------------------------------------------
// readConfigFile()
bool BookManager::readConfigFile() {
using namespace std;
// Just To Be Safe Incase This Function Is Called In Multiple Places
_mBookMarks.clear();
ifstream inFile( _strConfigFilename );
if ( inFile.fail() ) {
throw ExceptionHandler( __FUNCTION__ + std::string( " failed, could not open " ) + _strConfigFilename + std::string( " \nfor reading in book mark information \nInvalid file or file does not exist" ) );
}
// Read In The Book Mark Contents
std::vector<BookMark> vBookMarks;
BookMark bookMark;
string tempString = "";
if ( inFile.is_open() ) {
while ( !inFile.eof() ) {
BookMark bookMark;
getline( inFile, bookMark.strFilename );
inFile >> bookMark.id;
inFile >> bookMark.bookID;
inFile >> bookMark.chapterNumber;
inFile >> bookMark.pageNumber;
inFile >> bookMark.lineNumber;
inFile >> bookMark.columnNumber;
getline( iniFile, tempString );
//_mBookMarks.insert( make_pair( bookMark.id, bookMark ) );
vBookMarks.push_back( bookMark );
}
}
inFile.close();
return true;
} // readConfigFile
// ----------------------------------------------------------------------------
// writeConfigFile()
bool BookManager::writeConfigFile() {
using namespace std;
ofstream outFile;
outFile.open( _strConfigFilename, fstream::out );
if ( outFile.fail() ) {
throw ExceptionHandler( __FUNCTION__ + std::string( " failed, could not open " ) + _strConfigFilename + std::string( " \nfor writing book mark contents to file." ) );
}
// Write Out Book Mark Contents
if ( outFile.is_open() ) {
unsigned i = 0;
for ( i = 0; i < _mBookMarks.size(); i++ ) {
outFile << _mBookMarks.at( i ).strFilename << endl;
outFile << _mBookMarks.at( i ).id << " ";
outFile << _mBookMarks.at( i ).bookID << " ";
outFile << _mBookMarks.at( i ).chapterNumber << " ";
outFile << _mBookMarks.at( i ).pageNumber << " ";
outFile << _mBookMarks.at( i ).lineNumber << " ";
outFile << _mBookMarks.at( i ).columnNumber << endl << endl;
}
}
outFile.close();
return true;
} // writeConfigFile
The problem I am having is, when I call the write function all the text is being displayed properly in my text file. The first line should be a string that contains the book's title or filename. The second line should be all unsigned ints to specify parameters to know the position of the bookmark's location. As of now I just populated my classes structure with arbitrary data using a for loop and incrementing each bookmarks parameters just to test these functions. Somewhere else in my code I call my write method first to create this text file and write the contents. This seems to be working fine. Then I call my read method to read in the file and populate a temporary vector of my structure to see if the contents being read from the file are valid. Once I get this to work properly I'll then just populate my class's member variable structure instead.
Here I am reading in the first line using getline function then I am using the stream operators to get the rest of the contents. While I am debugging my code going through the read method and checking my temp vector the first element has the correct value with No Title and each of the parameters are 0. When I check the next element there is no string in the next BookMark structure object and all values are 0. Also there should only be 5 elements in my temp vector and it should break out of the loop, but it continues and never breaks out of the loop. Why is the code behaving like this? What is it that I am doing wrong? How can I change this to get the behavior I am looking for?
If you need to see this class in full let me know, but I think the rest of the class is not important as to what I am trying to do, only these two functions should be enough to describe my situation. Once I get this to work properly then I'll just change the read and write methods to work in binary as opposed to text.
I believe I have solved my own problem. In my read method, I had to add a second getline( this fileStream, tempString ); And now my code appears to be working properly. My vector has the correct values and it only has 5 elements and now breaks out of the loop.