Example #1
0
double calculateRMSE(std::map<int,geometry_msgs::PoseStamped> &poses1,
                     std::map<int,geometry_msgs::PoseStamped> &poses2)
{
    double ddt = 0;
    double dda = 0;

    for(std::map<int,geometry_msgs::PoseStamped>::iterator it = poses1.begin(), end = poses1.end();
        it != end; it++)
    {
        geometry_msgs::PoseStamped pose1 = it->second;
        geometry_msgs::PoseStamped pose2 = poses2[it->first];

        //
        double dx = pose1.pose.position.x - pose2.pose.position.x;
        double dy = pose1.pose.position.y - pose2.pose.position.y;
        double dz = pose1.pose.position.z - pose2.pose.position.z;
        ddt += dx*dx + dy*dy + dz*dz;

        //
        tf::Transform tr1 = poseToTransform(pose1.pose);
        tf::Transform tr2 = poseToTransform(pose2.pose);
        tf::Transform dq = tr1.inverse() * tr2;
        double da = dq.getRotation().getAngle();
        dda += da*da;
    }

    double rmse = sqrt(ddt / poses1.size());
    double rot_rmse = sqrt(dda / poses1.size());
    cout << BOLDWHITE << "RMSE trans = " << CYAN << rmse
         << BOLDWHITE << ", rot = " << CYAN << (rot_rmse * 180.0 / M_PI) << RESET << endl;
    return rmse;
}
Example #2
0
/** Callback called when we finish playing music. */
void musicFinished()
{
    Mix_HaltMusic();
    Mix_FreeMusic( current_music );
    current_music = nullptr;

    const auto iter = playlists.find( current_playlist );
    if( iter == playlists.end() ) {
        return;
    }
    const music_playlist &list = iter->second;
    if( list.entries.empty() ) {
        return;
    }

    // Load the next file to play.
    absolute_playlist_at++;

    // Wrap around if we reached the end of the playlist.
    if( absolute_playlist_at >= list.entries.size() ) {
        absolute_playlist_at = 0;
    }

    current_playlist_at = playlist_indexes.at( absolute_playlist_at );

    const auto &next = list.entries[current_playlist_at];
    play_music_file( next.file, next.volume );
}
void* handle_get_resource (int32_t handle)
{
	if (handles.count (handle) != 0)
		return handles.at (handle);

	return nullptr;
}
Example #4
0
// It always return a calibration structure, but it may be empty if the model
// name is unknown.
const VelodyneCalibration& VelodyneCalibration::LoadDefaultCalibration(
	const std::string& lidar_model)
{
	// Cached calib data?
	auto it = cache_default_calibs.find(lidar_model);
	if (it != cache_default_calibs.end()) return it->second;

	VelodyneCalibration result;  // Leave empty to indicate unknown model
	std::string xml_contents, yaml_contents;

	if (lidar_model == "VLP16")
		xml_contents = velodyne_default_calib_VLP16;
	else if (lidar_model == "HDL32")
		xml_contents = velodyne_default_calib_HDL32;
	else if (lidar_model == "HDL64")
		yaml_contents = velodyne_default_calib_HDL64E_S3;

	if (!xml_contents.empty())
	{
		if (!result.loadFromXMLText(xml_contents))
			std::cerr << "[VelodyneCalibration::LoadDefaultCalibration] Error "
						 "parsing default XML calibration file for model '"
					  << lidar_model << "'\n";
	}
	else if (!yaml_contents.empty())
	{
		if (!result.loadFromYAMLText(yaml_contents))
			std::cerr << "[VelodyneCalibration::LoadDefaultCalibration] Error "
						 "parsing default YAML calibration file for model '"
					  << lidar_model << "'\n";
	}

	cache_default_calibs[lidar_model] = result;
	return cache_default_calibs[lidar_model];
}
void saveKeyMappings()
{
	FILE *ff = fopen(KEYMAPPINGS_FILE, "w");
	if( !ff )
		return;
	for( std::map<int, int>::const_iterator it = keyMappings.begin(); it != keyMappings.end(); it++ )
		fprintf(ff, "%d=%d\n", it->first, it->second);
	fclose(ff);
	ff = fopen(KEYMAPPINGS_CTRL_FILE, "w");
	if( !ff )
		return;
	for( std::set<int>::const_iterator it = keyMappingsCtrl.begin(); it != keyMappingsCtrl.end(); it++ )
		fprintf(ff, "%d\n", *it);
	fclose(ff);
	ff = fopen(KEYMAPPINGS_SHIFT_FILE, "w");
	if( !ff )
		return;
	for( std::set<int>::const_iterator it = keyMappingsShift.begin(); it != keyMappingsShift.end(); it++ )
		fprintf(ff, "%d\n", *it);
	fclose(ff);
	ff = fopen(KEYMAPPINGS_ALT_FILE, "w");
	if( !ff )
		return;
	for( std::set<int>::const_iterator it = keyMappingsAlt.begin(); it != keyMappingsAlt.end(); it++ )
		fprintf(ff, "%d\n", *it);
	fclose(ff);
}
Example #6
0
    GLCharacter * operator[ ]( char const xCharacter )
    {
        GLCharacter * ret = NULL;

        if ( mCharacters.find( xCharacter ) == mCharacters.end( ) )
        {
//#ifdef ANDROID
#if 1
            mFont.loadGlyph( xCharacter, 0.0f );

            PNGImage output( { mFont.getGlyphWidth( ), mFont.getGlyphHeight( ) } );

            mFont.printSpans( output, mOutlineColor, mFillColor );

            mCharacters[ xCharacter ] = ret = new GLCharacter( xCharacter
                    , output.toGLTextureBuffer( )
                    , mFont.getGlyphWidth( )
                    , mFont.getGlyphHeight( ) );
#else
            while ( !fileExists( filename.str( ).c_str( ) ) ) {
                _makePNG( xCharacter );
            }
            mCharacters[ xCharacter ] = ret = new GLCharacter( xCharacter, filename.str( ).c_str( ) );
#endif

        }
        else
        {
            ret = mCharacters[ xCharacter ];
        }

        return ret;
    }
Example #7
0
void
registerHleModule(const std::string &name,
                  HleModule *module)
{
   if (std::find(decaf::config::system::lle_modules.begin(),
                 decaf::config::system::lle_modules.end(),
                 name) != decaf::config::system::lle_modules.end()) {
      gLog->warn("Replacing HLE with LLE for module {}.", name);
      return;
   }

   // Register module
   decaf_check(sHleModules.find(name) == sHleModules.end());
   sHleModules.emplace(name, module);

   // Register every function symbol
   auto &symbolMap = module->getSymbolMap();

   for (auto &pair : symbolMap) {
      auto symbol = pair.second;

      if (symbol->type == HleSymbol::Function) {
         registerHleFunc(reinterpret_cast<HleFunction *>(symbol));
      }
   }
}
Example #8
0
bool GD_API PickRandomObject(RuntimeScene & scene, std::map <std::string, std::vector<RuntimeObject*> *> pickedObjectLists)
{
    //Create a list with all objects
    std::vector<RuntimeObject*> allObjects;
    for (std::map <std::string, std::vector<RuntimeObject*> *>::iterator it = pickedObjectLists.begin();it!=pickedObjectLists.end();++it)
    {
        if ( it->second != NULL )
            std::copy(it->second->begin(), it->second->end(), std::back_inserter(allObjects));
    }

    if ( !allObjects.empty() )
    {
        unsigned int id = GDpriv::CommonInstructions::Random(allObjects.size()-1);
        RuntimeObject * theChosenOne = allObjects[id];

        for (std::map <std::string, std::vector<RuntimeObject*> *>::iterator it = pickedObjectLists.begin();it!=pickedObjectLists.end();++it)
        {
            if ( it->second != NULL ) it->second->clear();
        }

        if ( pickedObjectLists[theChosenOne->GetName()] != NULL ) pickedObjectLists[theChosenOne->GetName()]->push_back(theChosenOne);
    }

    return true;
}
Example #9
0
bool CNodeDefManager::getIds(const std::string &name,
		std::set<content_t> &result) const
{
	//TimeTaker t("getIds", NULL, PRECISION_MICRO);
	if (name.substr(0,6) != "group:") {
		content_t id = CONTENT_IGNORE;
		bool exists = getId(name, id);
		if (exists)
			result.insert(id);
		return exists;
	}
	std::string group = name.substr(6);

	std::map<std::string, GroupItems>::const_iterator
		i = m_group_to_items.find(group);
	if (i == m_group_to_items.end())
		return true;

	const GroupItems &items = i->second;
	for (GroupItems::const_iterator j = items.begin();
		j != items.end(); ++j) {
		if ((*j).second != 0)
			result.insert((*j).first);
	}
	//printf("getIds: %dus\n", t.stop());
	return true;
}
Example #10
0
time_t readImageTime(std::string path,std::string* pS=NULL)
{
    using namespace Exiv2;

    time_t       result       = 0 ;
	static std::map<std::string,time_t> cache;
	if ( cache.count(path) == 1 ) return cache[path];

    const char* dateStrings[] =
    { "Exif.Photo.DateTimeOriginal"
    , "Exif.Photo.DateTimeDigitized"
    , "Exif.Image.DateTime"
    , NULL
    };
    const char* ds            = dateStrings[0] ;

    while ( !result && ds++  ) {
        try {
            Image::AutoPtr image = ImageFactory::open(path);
            if ( image.get() ) {
                image->readMetadata();
                ExifData &exifData = image->exifData();
            //  printf("%s => %s\n",(ds-1), exifData[ds-1].toString().c_str());
                result = parseTime(exifData[ds-1].toString().c_str(),true);
                if ( result && pS ) *pS = exifData[ds-1].toString();
            }
        } catch ( ... ) {};
    }
	if ( result ) cache[path] = result;
    return result ;
}
Example #11
0
// TODO: How many handlers can the PSP actually have for Apctl?
// TODO: Should we allow the same handler to be added more than once?
u32 sceNetApctlAddHandler(u32 handlerPtr, u32 handlerArg) {
	bool foundHandler = false;
	u32 retval = 0;
	struct ApctlHandler handler;
	memset(&handler, 0, sizeof(handler));

	while (apctlHandlers.find(retval) != apctlHandlers.end())
		++retval;

	handler.entryPoint = handlerPtr;
	handler.argument = handlerArg;

	for(std::map<int, ApctlHandler>::iterator it = apctlHandlers.begin(); it != apctlHandlers.end(); it++) {
		if(it->second.entryPoint == handlerPtr) {
			foundHandler = true;
			break;
		}
	}

	if(!foundHandler && Memory::IsValidAddress(handlerPtr)) {
		if(apctlHandlers.size() >= MAX_APCTL_HANDLERS) {
			ERROR_LOG(SCENET, "UNTESTED sceNetApctlAddHandler(%x, %x): Too many handlers", handlerPtr, handlerArg);
			retval = ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS; // TODO: What's the proper error code for Apctl's TOO_MANY_HANDLERS?
			return retval;
		}
		apctlHandlers[retval] = handler;
		WARN_LOG(SCENET, "UNTESTED sceNetApctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval);
	}
	else
		ERROR_LOG(SCENET, "UNTESTED sceNetApctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg);


	// The id to return is the number of handlers currently registered
	return retval;
}
std::pair<MSVehicle*, SUMOReal>
MSLink::getLeaderInfo(const std::map<const MSLink*, std::string>& previousLeaders, SUMOReal dist) const {
    if (MSGlobals::gUsingInternalLanes && myJunctionInlane == 0) {
        // this is an exit link

        // there might have been a link leader from previous steps who still qualifies
        // but is not the last vehicle on the foe lane anymore
        std::map<const MSLink*, std::string>::const_iterator it = previousLeaders.find(this);
        if (it != previousLeaders.end()) {
            MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(it->second));
            if (leader != 0 && std::find(myFoeLanes.begin(), myFoeLanes.end(), leader->getLane()) != myFoeLanes.end()) {
                return std::make_pair(leader,
                                      dist - (leader->getLane()->getLength() - leader->getPositionOnLane()) - leader->getVehicleType().getLength());
            }
        }
        // now check for last vehicle on foe lane
        for (std::vector<MSLane*>::const_iterator i = myFoeLanes.begin(); i != myFoeLanes.end(); ++i) {
            assert((*i)->getLinkCont().size() == 1);
            MSLink* exitLink = (*i)->getLinkCont()[0];
            if (myLane == exitLink->getLane()) {
                MSVehicle* leader = (*i)->getLastVehicle();
                if (leader != 0) {
                    return std::make_pair(leader,
                                          dist - ((*i)->getLength() - leader->getPositionOnLane()) - leader->getVehicleType().getLength());
                }
            }
        }
    }
    return std::make_pair<MSVehicle*, SUMOReal>(0, 0);
}
Example #13
0
	uint16_t Gestalt(uint16_t trap)
	{
		// FUNCTION Gestalt (selector: OSType; VAR response: LongInt): OSErr;

		/*
		 * on entry:
		 * D0 Selector code
		 *
		 * on exit:
		 * A0 Response
		 * D0 Result code
		 *
		 */

		uint32_t selector = cpuGetDReg(0);
		uint32_t response;

		Log("%04x Gestalt('%s')\n", trap, ToolBox::TypeToString(selector).c_str());

		auto iter = GestaltMap.find(selector);

		if (iter == GestaltMap.end()) return gestaltUndefSelectorErr;
		response = iter->second;
		cpuSetAReg(0, response);

		return 0;
	}
//
// Close all open handles to temporary files; usually only needed if
// there is a catastrophic failure, such as an exception in the VM.
//
void Compiler::DestroyTempFiles()
{
	for(std::map<CompileSessionHandle, CompileSessionData*>::iterator iter = CompileSessionMap.begin(); iter != CompileSessionMap.end(); ++iter)
		delete iter->second;

	CompileSessionMap.clear();
}
Example #15
0
STATIC std::string Template::doSubstitutions( std::string sourceCode, std::map< std::string, Value *> valueByName ) {
    int startI = 1;
    if( sourceCode.substr(0,2) == "{{" ) {
        startI = 0;
    }
    string templatedString = "";
    vector<string> splitSource = split( sourceCode, "{{" );
    if( startI == 1 ) {
        templatedString = splitSource[0];
    }
    for( int i = startI; i < splitSource.size(); i++ ) {
        vector<string> thisSplit = split( splitSource[i], "}}" );
        string name = trim( thisSplit[0] );
//        cout << "name: " << name << endl;
        if( valueByName.find( name ) == valueByName.end() ) {
            throw render_error( "name " + name + " not defined" );
        }
        Value *value = valueByName[ name ];
        templatedString += value->render();
        if( thisSplit.size() > 0 ) {
            templatedString += thisSplit[1];
        }
    }
    return templatedString;
}
static void rasterizeAABBs( const std::vector<AABB>& aabbs, const Array2s& min_coord, const scalar& h, const Array2u& dimensions, std::map<unsigned,std::vector<unsigned>>& voxels )
{
  // For each bounding box
  for( std::vector<AABB>::size_type aabb_idx = 0; aabb_idx < aabbs.size(); ++aabb_idx )
  {
    // Compute the cells the AABB overlaps with. Slightly enlarge the boxes to account for FPA errors.
    Array2u index_lower;
    computeCellIndex( aabbs[aabb_idx].min() - 1.0e-6, min_coord, h, index_lower );
    Array2u index_upper;
    computeCellIndex( aabbs[aabb_idx].max() + 1.0e-6, min_coord, h, index_upper );
    assert( ( index_lower <= index_upper ).all() );

    for( unsigned x_idx = index_lower.x(); x_idx <= index_upper.x(); ++x_idx )
    {
      for( unsigned y_idx = index_lower.y(); y_idx <= index_upper.y(); ++y_idx )
      {
        // Compute the hash key for the given indexed voxel
        const unsigned key = keyForIndex( Array2u( x_idx, y_idx ), dimensions );

        auto voxel_iterator = voxels.find( key );
        // Create a new voxel, if needed
        if( voxel_iterator == voxels.end() )
        {
          const auto insertion_result = voxels.insert( std::make_pair( key, std::vector<unsigned>{} ) );
          assert( insertion_result.second );
          voxel_iterator = insertion_result.first;
        }
        // Add the index of the AABB to the voxel
        voxel_iterator->second.emplace_back( aabb_idx );
      }
    }
  }
}
Example #17
0
cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id)
{
	cudaError_t result = cudaSuccess;
	if (abort_flag)
		return result;
	if (situation >= 0)
	{
		static std::map<int, tsumarray> tsum;

		double a = 0.95, b = 0.05;
		if (tsum.find(situation) == tsum.end()) { a = 0.5; b = 0.5; } // faster initial convergence

		double tsync = 0.0;
		double tsleep = 0.95 * tsum[situation].value[thr_id];
		if (cudaStreamQuery(stream) == cudaErrorNotReady)
		{
			usleep((useconds_t)(1e6*tsleep));
			struct timeval tv_start, tv_end;
			gettimeofday(&tv_start, NULL);
			result = cudaStreamSynchronize(stream);
			gettimeofday(&tv_end, NULL);
			tsync = 1e-6 * (tv_end.tv_usec-tv_start.tv_usec) + (tv_end.tv_sec-tv_start.tv_sec);
		}
		if (tsync >= 0) tsum[situation].value[thr_id] = a * tsum[situation].value[thr_id] + b * (tsleep+tsync);
	}
	else
		result = cudaStreamSynchronize(stream);
	return result;
}
Example #18
0
void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints)
{
    // Called after a match has ended and the stats are already modified
    // Helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons)
    // 10 played games per week is a minimum
    if(Stats.WeekGames < 10)
        return;

    // To get points, a player has to participate in at least 30% of the matches
    uint32 requiredGames = (uint32) ceil(Stats.WeekGames * 0.3);

    for(MemberList::const_iterator itr = Members.begin(); itr !=  Members.end(); ++itr)
    {
        // The player participated in enough games, update his points
        uint32 pointsToAdd = 0;
        if(itr->WeekGames >= requiredGames)
            pointsToAdd = GetPoints(itr->PersonalRating);

        std::map<uint32, uint32>::iterator plr_itr = playerPoints.find(GUID_LOPART(itr->Guid));
        if(plr_itr != playerPoints.end())
        {
            // Check if there is already more points
            if(plr_itr->second < pointsToAdd)
                playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd;
        }
        else
            playerPoints[GUID_LOPART(itr->Guid)] = pointsToAdd;
    }
}
Example #19
0
void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& PlayerPoints)
{
    // called after a match has ended and the stats are already modified
    // helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons)
    // 10 played games per week is a minimum
    if (m_stats.games_week < 10)
        return;
    // to get points, a player has to participate in at least 30% of the matches
    uint32 min_plays = (uint32) ceil(m_stats.games_week * 0.3);
    for(MemberList::const_iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        // the player participated in enough games, update his points
        uint32 points_to_add = 0;
        if (itr->games_week >= min_plays)
            points_to_add = GetPoints(itr->personal_rating);
        // OBSOLETE : CharacterDatabase.PExecute("UPDATE arena_team_member SET points_to_add = '%u' WHERE arenateamid = '%u' AND guid = '%u'", points_to_add, m_TeamId, itr->guid);

        std::map<uint32, uint32>::iterator plr_itr = PlayerPoints.find(itr->guid.GetCounter());
        if (plr_itr != PlayerPoints.end())
        {
            //check if there is already more points
            if (plr_itr->second < points_to_add)
                PlayerPoints[itr->guid.GetCounter()] = points_to_add;
        }
        else
            PlayerPoints[itr->guid.GetCounter()] = points_to_add;
    }
}
Example #20
0
bool FunctionGet(uint Address, uint* Start, uint* End)
{
    // CHECK: Exported function
    if(!DbgIsDebugging())
        return false;

    const uint moduleBase = ModBaseFromAddr(Address);

    // Lookup by module hash, then function range
    SHARED_ACQUIRE(LockFunctions);

    auto found = functions.find(ModuleRange(ModHashFromAddr(moduleBase), Range(Address - moduleBase, Address - moduleBase)));

    // Was this range found?
    if(found == functions.end())
        return false;

    if(Start)
        *Start = found->second.start + moduleBase;

    if(End)
        *End = found->second.end + moduleBase;

    return true;
}
Example #21
0
void CauchyGenerator::Init(std::map<std::string, double> params)
{
    assert(params.count("location") && params.count("scale"));
    mLocation = params["location"];
    mScale = params["scale"];
    assert(mScale > 0);
}
Example #22
0
void PrintStats(const std::map<T, int>& stats, int total)
{
    for (auto it = stats.begin(); it != stats.end(); ++it)
    {
        std::cerr << "   " << (*it).first << " : " << (*it).second << " / " << total << std::endl;
    }
}
Example #23
0
int Filesystem::listdir_recursive (std::string dir, std::map<std::string, bool> &files,
    int depth /* = 10 */, std::string prefix /* = "" */)
{
    int err;
    if (depth < 0)
        return -1;
    if (prefix == "")
        prefix = dir;
    std::vector<std::string> tmp;
    err = listdir(dir, tmp);
    if (err)
        return err;
    for (auto file = tmp.begin(); file != tmp.end(); ++file)
    {
        if (*file == "." || *file == "..")
            continue;
        std::string rel_path = prefix + "/" + *file;
        if (isdir(rel_path))
        {
            files.insert(std::pair<std::string, bool>(rel_path, true));
            err = listdir_recursive(dir + "/" + *file, files, depth - 1, rel_path);
            if (err)
                return err;
        }
        else
        {
            files.insert(std::pair<std::string, bool>(rel_path, false));
        }
    }
    return 0;
}
//---------------------------------------------------------------------------
void TfrmRatTanksBoxSelection::setUp(std::map<std::string,std::map<std::string,std::string> > &aliquotsBoxTypes, std::string &defaultBox)
{
	m_aliquotsBoxTypes = aliquotsBoxTypes;
	bool hasDefault = false;

	{
		std::map<std::string,std::map<std::string,std::string> >::iterator itBoxTypes = aliquotsBoxTypes.begin();
		for (;itBoxTypes!=aliquotsBoxTypes.end();++itBoxTypes)
		{
			if (!hasDefault)
			{
				if (itBoxTypes->first == defaultBox)
					hasDefault = true;
			}

			util_stdStringmapHolder *ValueHolder = new util_stdStringmapHolder(itBoxTypes->second);
			String s = String(String(itBoxTypes->second["external_name"].c_str())); //external_name
			boxTypeComboBox->AddItem(s,ValueHolder);
		}
	}
	if (hasDefault)
	{
		boxTypeComboBox->Text = String(defaultBox.c_str());
		NoButton->Enabled = true;
	}
	else
		boxTypeComboBox->Text = "Please select";

}
Example #25
0
void NetCDFFile::GetVariablesAttributes(std::vector< std::string > &attributeNames,
                                        std::vector< std::string > &attributeValues,
                                        const std::string &variableName) const
{
    const netCDF::NcVar var = getVariable( variableName );
    
    if( sofa::NcUtils::IsValid( var ) == true )
    {
        const std::map< std::string, netCDF::NcVarAtt > attributes = var.getAtts();
        
        const std::size_t size = attributes.size();
        attributeNames.resize( size );
        attributeValues.resize( size );
        
        std::size_t i = 0;
        for( std::multimap< std::string, netCDF::NcVarAtt >::const_iterator it = attributes.begin();
            it != attributes.end();
            ++it )
        {
            attributeNames[i]   = (*it).first;
            const netCDF::NcVarAtt att = (*it).second;
            
            attributeValues[i] = sofa::NcUtils::GetAttributeValueAsString( att );
            
            i++;
        }
    }
    else
    {
        attributeNames.clear();
        attributeValues.clear();
    }
}
Example #26
0
	void ApplyHashMap() {
		UpdateHashToFunctionMap();

		for (auto mf = hashMap.begin(), end = hashMap.end(); mf != end; ++mf) {
			auto iter = hashToFunction.find(mf->hash);
			if (iter == hashToFunction.end()) {
				continue;
			}

			// Yay, found a function.

			for (unsigned int i = 0; i < iter->second.size(); i++) {
				AnalyzedFunction &f = *(iter->second[i]);
				if (f.hash == mf->hash && f.size == mf->size) {
					strncpy(f.name, mf->name, sizeof(mf->name) - 1);

					std::string existingLabel = symbolMap.GetLabelString(f.start);
					char defaultLabel[256];
					// If it was renamed, keep it.  Only change the name if it's still the default.
					if (existingLabel.empty() || existingLabel == DefaultFunctionName(defaultLabel, f.start)) {
						symbolMap.SetLabelName(mf->name, f.start);
					}
				}
			}
		}
	}
Example #27
0
void play_music( const std::string &playlist )
{
    const auto iter = playlists.find( playlist );
    if( iter == playlists.end() ) {
        return;
    }
    const music_playlist &list = iter->second;
    if( list.entries.empty() ) {
        return;
    }

    // Don't interrupt playlist that's already playing.
    if( playlist == current_playlist ) {
        return;
    }

    for( size_t i = 0; i < list.entries.size(); i++ ) {
        playlist_indexes.push_back( i );
    }
    if( list.shuffle ) {
        static auto eng = std::default_random_engine(
                              std::chrono::system_clock::now().time_since_epoch().count() );
        std::shuffle( playlist_indexes.begin(), playlist_indexes.end(), eng );
    }

    current_playlist = playlist;
    current_playlist_at = playlist_indexes.at( absolute_playlist_at );

    const auto &next = list.entries[current_playlist_at];
    play_music_file( next.file, next.volume );
}
Example #28
0
static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
{
    if (lockstack.get() == NULL)
        lockstack.reset(new LockStack);

    if (fDebug) printf("Locking: %s\n", locklocation.ToString().c_str());
    dd_mutex.lock();

    (*lockstack).push_back(std::make_pair(c, locklocation));

    if (!fTry) {
        BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) {
            if (i.first == c) break;

            std::pair<void*, void*> p1 = std::make_pair(i.first, c);
            if (lockorders.count(p1))
                continue;
            lockorders[p1] = (*lockstack);

            std::pair<void*, void*> p2 = std::make_pair(c, i.first);
            if (lockorders.count(p2))
            {
                potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
                break;
            }
        }
    }
Example #29
0
void CmdHeaptrace::onClient(DebuggerClient &client) {
  if (DebuggerCommand::displayedHelp(client)) return;

  String format;
  String file;
  if (client.argCount() == 3) {
    format = client.argValue(2);
    file = client.argValue(3);
  } else if (client.argCount() != 1) {
    help(client);
    return;
  }

  CmdHeaptracePtr cmd = client.xend<CmdHeaptrace>(this);

  if (file.empty()) {
    cmd->printHeap(client);
  } else {
    std::string formatStr = format->data();
    const auto it = s_formatMap.find(formatStr);

    if (it == s_formatMap.end()) {
      client.print("Unsupported format type");
      return;
    }
    cmd->printGraphToFile(client, file, it->second);
  }

}
Example #30
0
void addDeltaPoses(std::map<int,geometry_msgs::PoseStamped> &inposes,
                   tf::Transform &delta,
                   std::map<int,geometry_msgs::PoseStamped> &outposes)
{
//    double roll, pitch, yaw;
//    tf::Matrix3x3 m33 (delta.getRotation());
//    m33.getRPY(roll, pitch, yaw);
//    cout << BOLDWHITE << " delta tf: " << CYAN << delta.getOrigin().x()
//         << " " << delta.getOrigin().y() << " " << delta.getOrigin().z()
//         << " " << roll << " " << pitch << " " << yaw << RESET << endl;

    for(std::map<int,geometry_msgs::PoseStamped>::iterator it = inposes.begin(), end = inposes.end();
        it != end; it++)
    {
        int seq = it->first;
        geometry_msgs::PoseStamped pose = it->second;
        //
        tf::Transform trans = poseToTransform(pose.pose);
        tf::Transform rt = delta*trans;
        geometry_msgs::PoseStamped ps;
        ps.pose = transformToPose(rt);
        ps.header = pose.header;

        //
        outposes.insert(std::pair<int,geometry_msgs::PoseStamped>(seq, ps));
    }
}