Navigation

    Robolink logo
    • Register
    • Login
    • Search
    • [[global:header.categories]]
    • [[global:header.recent]]
    • [[global:header.tags]]
    • [[global:header.popular]]
    • [[global:header.users]]
    • [[global:header.groups]]
    As of September 2021, we have moved technical support to Robolink Help

    Welcome to the Robolink Community forum!

    You can post here to interact with others in the Robolink community. We're checking it weekly, and we'll respond to some messages. If you're looking for technical support, head over to Robolink Help.

    Regarding irMassageRecieve

    CoDrone Lite/Pro
    3
    7
    5823
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      magnus last edited by

      Hi,

      I have modified the battle method in the cpp to return an integer if there is a hit by a opposing team.
      It seems like irMassageReceive does not contain the Missile.
      I have tried removing the
      "if(irMassageReceive == BLUE_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)" and only check one at a time.

      The outer check of team-variable works. But I cant get it to sense the missile. Any ideas? The weapon is set to correct. I see the light flashing on the bluetooth so I know it receives data. And I know some data is received by the Receive() method since the irMassageReceive is larger than 0.

      1 Reply Last reply Reply Quote 0
      • robolink_arnold
        robolink_arnold last edited by

        Here is the modification I did

        unsigned long CoDroneClass::BattleReceive()
        {
           Receive();
        
           if(irMassageReceive > 0)
           {
        
           	if(team == TEAM_RED)
           	{
           		if(irMassageReceive == BLUE_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)
           		{
           			BattleDamageProcess();		
           		}			
           	}						
           	else if(team == TEAM_BLUE)
           	{
           		if(irMassageReceive == RED_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)
           		{				
           			BattleDamageProcess();
           		}			
           	}					
           	else if(team == TEAM_GREEN)
           	{
           		if(irMassageReceive == BLUE_MISSILE || irMassageReceive == RED_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)
           		{
           				BattleDamageProcess();				
           		}			
           	}		
           	else if(team == TEAM_YELLOW)
           	{
           		if(irMassageReceive == BLUE_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == RED_MISSILE || irMassageReceive == FREE_MISSILE)
           		{				
           			BattleDamageProcess();
           		}			
           	}			
           	else if(team == FREE_PLAY)
           	{
           		if(irMassageReceive == RED_MISSILE || irMassageReceive == BLUE_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_PLAY)
           		{				
           			BattleDamageProcess();
           		}			
           	}		
           	unsigned long returnIRMSG = irMassageReceive;
           	irMassageReceive = 0;
           	return returnIRMSG;
           }
        }
        

        and then in the main arduino code I call

          CoDrone.BattleShooting();
          unsigned long irmsg = CoDrone.BattleReceive();
          CoDrone.Send_LinkModeBroadcast(LinkModeMute);
          delay(200);
          Serial.println("-----------");
          Serial.println(irmsg);
          Serial.println("-----------");
          delay(200);
          CoDrone.Send_LinkModeBroadcast(LinkBroadcast_Active);
        

        I have the Drone shoot a wall so the IR code can bounce off. Let me know if this helps.

        1 Reply Last reply Reply Quote 0
        • M
          magnus last edited by

          Yes. I changed it to match the instatiated methods in the cpp file.
          Meaning in the header:

          int BattleRecieve();
          instead of
          void BattleRecieve();

          1 Reply Last reply Reply Quote 0
          • robolink_arnold
            robolink_arnold last edited by

            @magnus did you change the header file?

            1 Reply Last reply Reply Quote 0
            • robolink_wes
              robolink_wes last edited by

              @robolink_arnold and @robolink_whoseop Can you two take a look at this and get back to Magnus? Thanks!

              1 Reply Last reply Reply Quote 0
              • M
                magnus last edited by

                void CoDroneClass::BattleBegin(byte teamSelect)
                {
                	team = teamSelect;
                	if(team == TEAM_RED)
                	{		
                		weapon = RED_MISSILE;
                	}		
                	else if	(team == TEAM_BLUE)
                	{		
                		weapon = BLUE_MISSILE;
                	}	
                	delay (300);
                
                }
                
                int CoDroneClass::BattleReceive()
                {
                	Receive();
                	int result = -1;
                
                	if(irMassageReceive > 0)
                	{		
                		if(team == TEAM_RED)
                		{
                			if(irMassageReceive == BLUE_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)
                			{
                				result = 1;	
                			}			
                
                		}						
                		else if(team == TEAM_BLUE)
                		{
                
                			if(irMassageReceive == RED_MISSILE || irMassageReceive == GREEN_MISSILE || irMassageReceive == YELLOW_MISSILE || irMassageReceive == FREE_MISSILE)
                			{				
                				result = 2;
                
                			}			
                		}					
                
                		irMassageReceive = 0;
                	}
                
                	return result;
                }
                

                I first instantiate weapon and team in battlebegin. I just removed the color settings.
                Then I make the BattleRecieve function return a value if one drone gets hit by the opponent. (I also change the .h file ofcourse. Everything compile)

                I want to do this to send instructions to another drone. When one drone shoots the other should respond by taking off and perform its flightprogram.

                Next in my arduino:

                void setup
                {
                     CoDrone.BattleBegin(TEAM_BLUE);
                }
                
                int information = -1;
                
                void loop
                {
                    information = CoDrone.BattleReceive();
                    byte bt8 = DrigitalRead(11);
                
                    if(information==1)
                   {
                        //Flight instructions here
                   }
                   if(bt8)
                   {
                         CoDrone.BattleShooting();
                   }
                }
                

                The Same code is used on the other drone except a different team color.
                I see that the bluetooth diod is flashing crazy when I shoot and hit the drone but I dont get the loop to start in my opponent
                .

                1 Reply Last reply Reply Quote 0
                • robolink_arnold
                  robolink_arnold last edited by

                  @magnus I will get back to you on this, we have not used irMassageReceive in our Arduino tutorials. Can you post the modification you made? like the whole function.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post