Project

General

Profile

Revision 46ed9b9b

ID46ed9b9b14c03bc0931b775634e76ca85b9fd7de
Parent 8ae3771a
Child 64b6024c

Added by Yuyang Guo over 10 years ago

simulate multiple bom emitters with different ids

View differences:

scout/scoutsim/src/sim_frame.cpp
69 69
                  wxSize(500, 500), wxDEFAULT_FRAME_STYLE & ~wxRESIZE_BORDER)
70 70
          , frame_count(0)
71 71
          , id_counter(0)
72
          , BOM_counter(0)
72 73
    {
73 74
        std::cout << "Constructing sim frame." << std::endl;
74 75

  
......
358 359
            do
359 360
            {
360 361
                std::stringstream ss;
361
                ss << "emitter" << ++id_counter;
362
                ss << "emitter_" << ++BOM_counter;
362 363
                real_name = ss.str();
363 364
            }
364 365
            while (hasEmitter(real_name));
......
734 735
            double y_offset;    
735 736
            double offset_angle;
736 737
            double diag_dis = pow((pow((SCOUT_W/2.0),2) + 
737
                              pow((SCOUT_H/2.0),2)),(0.5));   
738
                    
738
                              pow((SCOUT_H/2.0),2)),(0.5));
739

  
739 740
                for (int i = 0; i<10; i++) {
740 741
                geometry_msgs::Pose2D bom_pos;
741 742
                
......
785 786
                }
786 787

  
787 788
                if(is_inrange(emitter_pos, bom_pos, bom_aperture, bom_distance)) {
788
                        
789
                        it->second->update_BOM(i, 1, 0);
790
                            // TODO: change to last arg to actual sender ID
791
                        
792
                    }
789
                    string em_id_str = it->first.substr(it->first.find("_"));
790
                    int emitter_id = atoi(em_id_str.c_str());
791
                    it->second->update_BOM(i, 1, emitter_id);
792
                }
793 793
                else {
794
                        
795
                        it->second->update_BOM(i, 0, 0);
796
                            // TODO: change to last arg to actual sender ID
797
                        
794
                    it->second->update_BOM(i, 0, 0);
798 795
                }
799 796
                }
800
                
801 797
            }
802 798
        }
803 799

  
......
818 814
        ROS_INFO("Resetting scoutsim.");
819 815
        scouts.clear();
820 816
        id_counter = 0;
817
        BOM_counter = 0;
818

  
821 819
        spawnScout("", width_in_meters / 2.0, height_in_meters / 2.0, 0);
822 820
        clear();
823 821
        return true;
scout/scoutsim/src/sim_frame.h
200 200
            M_Emitter emitters;
201 201
            std::vector<GhostScout*> ghost_scouts;
202 202
            uint32_t id_counter;
203
            uint32_t BOM_counter;
203 204

  
204 205
            std::string images_path;
205 206

  

Also available in: Unified diff