Example #1
0
void printToConsole(const char* txt)
{
	static int handle=-1;
	std::string text(txt);
	text+="\n";
	std::cout << text;
	if (simAuxiliaryConsolePrint(handle,text.c_str())<=0)
	{
		handle=simAuxiliaryConsoleOpen("URDF import",5000,2+4,NULL,NULL,NULL,NULL);
		simAuxiliaryConsolePrint(handle,text.c_str());
	}
}
Example #2
0
void CSubscriberData::auxiliaryConsolePrintCallback(const std_msgs::String::ConstPtr& txt)
{
	if (txt->data.length()==0)
	{
		if (simAuxiliaryConsolePrint(auxInt1,NULL)<=0)
			shutDownGeneralSubscriber();
	}
	else
	{
		if (simAuxiliaryConsolePrint(auxInt1,txt->data.c_str())<=0)
			shutDownGeneralSubscriber();
	}
}
Example #3
0
VREP_DLLEXPORT void* v_repMessage(int message,int* auxiliaryData,void* customData,int* replyData)
{ // This is called quite often. Just watch out for messages/events you want to handle
	simLockInterface(1);
	// This function should not generate any error messages:
	int errorModeSaved;
	simGetIntegerParameter(sim_intparam_error_report_mode,&errorModeSaved);
	simSetIntegerParameter(sim_intparam_error_report_mode,sim_api_errormessage_ignore);

	void* retVal=NULL;


	// Acknowledgment message display:
	// *****************************************************************
	static int auxConsoleHandleForAcknowledgmentDisplay=-1;
	static int acknowledgmentDisplayStartTime=0;
	if (displayAcknowledgment)
	{
		auxConsoleHandleForAcknowledgmentDisplay=simAuxiliaryConsoleOpen("Acknowledgments",10,2+4+16,NULL,NULL,NULL,NULL);
		simAuxiliaryConsolePrint(auxConsoleHandleForAcknowledgmentDisplay,"The wiimote plugin is courtesy of Eric Rohmer.\n\nThe wiimote plugin contains WiiYourself! wiimote code by gl.tter\nhttp://gl.tter.org");
		acknowledgmentDisplayStartTime=timeGetTime();
		displayAcknowledgment=false;
	}
	if ( (auxConsoleHandleForAcknowledgmentDisplay!=-1)&&(timeGetTime()-acknowledgmentDisplayStartTime>5000) )
	{
		simAuxiliaryConsoleClose(auxConsoleHandleForAcknowledgmentDisplay);
		auxConsoleHandleForAcknowledgmentDisplay=-1;
	}
	// *****************************************************************

	// Clean-up at simulation end:
	// *****************************************************************
	if (message==sim_message_eventcallback_simulationended)
	{
		if (auxConsoleHandleForAcknowledgmentDisplay!=-1)
		{
			simAuxiliaryConsoleClose(auxConsoleHandleForAcknowledgmentDisplay);
			auxConsoleHandleForAcknowledgmentDisplay=-1;
		}
		for (int i=0;i<4;i++) // for the 4 devices
		{
			while (startCountPerDevice[i]>0)
			{
				startCountOverall--;
				startCountPerDevice[i]--;
				if (startCountOverall==0)
					killThread();
			}
		}
	}
	// *****************************************************************

	simSetIntegerParameter(sim_intparam_error_report_mode,errorModeSaved); // restore previous settings
	simLockInterface(0);
	return(retVal);
}
void CSimxSocket::instancePass()
{
// 3/3/2014
//	if (!_simulationOnly)
	{
		int simState=simGetSimulationState();
		if ((simState&sim_simulation_advancing)==0)
			_executeCommands();
	}

	if (_debug)
	{ // we should never access the V-REP API from a thread not created in V-REP!
		_lock();
		for (unsigned int i=0;i<_textToPrintToConsole.size();i++)
			simAuxiliaryConsolePrint(_auxConsoleHandle,_textToPrintToConsole[i].c_str());
		_textToPrintToConsole.clear();
		_unlock();
	}
}