ROBOTC.net forums
http://robotc.net/forums/

IR seeker #include file not locating
http://robotc.net/forums/viewtopic.php?f=52&t=5513
Page 1 of 1

Author:  hrazo6332 [ Tue Feb 19, 2013 1:27 am ]
Post subject:  IR seeker #include file not locating

can somebody please help me it's my first time using the IR seeker sensor. I'm trying to use Xander's 3rd party sensors but the #include file gives me errors when I compile it. I'm not sure what is wrong. could someone please help me?

Author:  mightor [ Tue Feb 19, 2013 1:18 pm ]
Post subject:  Re: IR seeker #include file not locating

Did you follow all of the instructions here: http://botbench.com/blog/robotc-driver- ... ver-suite/

= Xander

Author:  Coder A [ Tue Feb 19, 2013 3:11 pm ]
Post subject:  Re: IR seeker #include file not locating

Something that could be wrong is the name of the include file. Let's say you had the Dexter Industries IMU. The include file I'm told to use is "drivers/dexterind-imu.h", but that gets me an error. I changed it to "dexterind-imu.h" and it worked. It could be something as simple as that.

Author:  hrazo6332 [ Tue Feb 19, 2013 6:32 pm ]
Post subject:  Re: IR seeker #include file not locating

I got it working but now it says there is a duplicate definition for task 'main'. why is it saying that?

Author:  Coder A [ Tue Feb 19, 2013 8:16 pm ]
Post subject:  Re: IR seeker #include file not locating

Would you mind to copy and paste the code so we can see? I've had that problem before and I'm sure I can fix it if you show me the code.

Author:  hrazo6332 [ Wed Feb 20, 2013 12:47 pm ]
Post subject:  Re: IR seeker #include file not locating

#pragma config(Hubs, S1, HTServo, HTMotor, HTMotor, none)
#pragma config(Sensor, S2, HTIRS2, sensorI2CCustom)
#pragma config(Motor, mtr_S1_C2_1, rightside, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, leftside, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, ringlift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, motorG, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C1_1, IRservo, tServoStandard)
#pragma config(Servo, srvo_S1_C1_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C1_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C1_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C1_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C1_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
#include "hitechnic-irseeker-v2-test1.c"


task main ()
{
waitForStart(); // Wait for the beginning of autonomous phase.

while (true)

motor[ringlift] = 10;

wait10Msec(200);


servo[IRservo] = 0;

wait10Msec(600);

while (SensorValue[HTIRS2]<5)
{
motor[rightside] = 75;
motor[leftside] = 75;
}
wait10Msec(1000);

while (SensorValue[HTIRS2]==5)
{
motor[rightside] = 50;
motor[leftside] = -50;
}
wait10Msec(2000);

servo[IRservo] = 127;
wait10Msec(600);

while (SensorValue[HTIRS2] ==5)
{
motor[rightside] = 30;
motor[leftside] = 30;
}
wait10Msec(5000);

motor[ringlift] = -10;
wait10Msec(2000);

motor[rightside] = -30;
motor[leftside] = -30;
wait10Msec(6000);
}

Author:  mightor [ Wed Feb 20, 2013 1:17 pm ]
Post subject:  Re: IR seeker #include file not locating

You need to include the driver, not the test program :)
Change the include line to this:
Code:
#include "drivers/hitechnic-irseeker-v2.h"

= Xander

Author:  JohnWatson [ Wed Feb 20, 2013 1:20 pm ]
Post subject:  Re: IR seeker #include file not locating

One other thing I saw that will cause you issues:

Code:
while (true)

motor[ringlift] = 10;


This will only run the motor[rightlift]=10; code continuously; to have the entire program run inside the infinite loop, you will need to use the opening and closing braces:

Code:
while(true)
{
//Code goes here
}

Author:  hrazo6332 [ Wed Feb 20, 2013 1:27 pm ]
Post subject:  Re: IR seeker #include file not locating

the same error comes up and when I put #include "drivers/hitechnic-irseeker-v2.h" the same error from before comes up also.

Author:  mightor [ Wed Feb 20, 2013 3:31 pm ]
Post subject:  Re: IR seeker #include file not locating

Did you remove the erroneous line:
Code:
#include "hitechnic-irseeker-v2-test1.c"

= Xander

Author:  hrazo6332 [ Wed Feb 20, 2013 5:31 pm ]
Post subject:  Re: IR seeker #include file not locating

i put that up now and it didn't show any errors at all. I tried it on my robot but there is no response. I checked the NXT and the FMS messages are at zero. Could this be the problem?

MY code now looks like this:

#pragma config(Hubs, S1, HTServo, HTMotor, HTMotor, none)
#pragma config(Sensor, S2, HTIRS2, sensorI2CCustom)
#pragma config(Motor, mtr_S1_C2_1, rightside, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_2, leftside, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, ringlift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, motorG, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C1_1, IRservo, tServoStandard)
#pragma config(Servo, srvo_S1_C1_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C1_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C1_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C1_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C1_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
#include "drivers/hitechnic-irseeker-v2.h"

task main ()
{
waitForStart(); // Wait for the beginning of autonomous phase.

while (true)
{
motor[ringlift] = 10;

wait10Msec(200);
}

servo[IRservo] = 0;

wait10Msec(600);

while (SensorValue[HTIRS2]<5)
{
motor[rightside] = 75;
motor[leftside] = 75;
}
wait10Msec(1000);

while (SensorValue[HTIRS2]==5)
{
motor[rightside] = 50;
motor[leftside] = -50;
}
wait10Msec(2000);

servo[IRservo] = 127;
wait10Msec(600);

while (SensorValue[HTIRS2] ==5)
{
motor[rightside] = 30;
motor[leftside] = 30;
}
wait10Msec(5000);
{
motor[ringlift] = -10;
wait10Msec(2000);
}
motor[rightside] = -30;
motor[leftside] = -30;
wait10Msec(6000);
}

Author:  JohnWatson [ Wed Feb 20, 2013 5:52 pm ]
Post subject:  Re: IR seeker #include file not locating

Code:
while (true)
{
motor[ringlift] = 10;

wait10Msec(200);
}


This is going to give you the same issues as before; only the motor[ringlift] = 10; and wait10Msec(200); commands will run repeatedly. To ensure that the entire program gets looped, make sure you place all of the code you want to run inside of the { and } of the 'while(true)' loop.

You can use ROBOTC's autoformat tool to automatically indent the code, which should make it a little bit easier to determine where the braces are (fourth icon from the left, the one that has the purple sparkles around it).

Image

Author:  hrazo6332 [ Wed Feb 20, 2013 6:25 pm ]
Post subject:  Re: IR seeker #include file not locating

I tried that out but the whole code gets highlighted. I'm not sure if that is what you meant. When I try it on my robot it responds but only the ring lift motor moves and the only way to stop it is to stop the whole program. is there I way I could replace the timing for the rotation statement instead?

Author:  l0jec [ Fri Mar 08, 2013 11:01 am ]
Post subject:  Re: IR seeker #include file not locating

As JohnWatson said, your code is stuck in the while(true) loop and never executes any statements beyond that.

Code:
   while (true)
   {
      motor[ringlift] = 10;

      wait10Msec(200);
   }

This while loop will never end; your code is stuck executing the two statements inside forever. This matches the behavior you describe.

This appears to be an autonomous routine to me, so there is no need for the while(true) loop in your code best I can tell. Simply remove it like below:
Code:
#pragma config(Hubs, S1, HTServo, HTMotor, HTMotor, none)
#pragma config(Sensor, S2, HTIRS2, sensorI2CCustom)
#pragma config(Motor, mtr_S1_C2_1, rightside, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_2, leftside, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, ringlift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, motorG, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C1_1, IRservo, tServoStandard)
#pragma config(Servo, srvo_S1_C1_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C1_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C1_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C1_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C1_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
#include "drivers/hitechnic-irseeker-v2.h"

task main ()
{
   waitForStart(); // Wait for the beginning of autonomous phase.

   motor[ringlift] = 10;
   wait10Msec(200);

   servo[IRservo] = 0;
   wait10Msec(600);

   while (SensorValue[HTIRS2]<5)
   {
      motor[rightside] = 75;
      motor[leftside] = 75;
   }
   wait10Msec(1000);

   while (SensorValue[HTIRS2]==5)
   {
      motor[rightside] = 50;
      motor[leftside] = -50;
   }
   wait10Msec(2000);

   servo[IRservo] = 127;
   wait10Msec(600);

   while (SensorValue[HTIRS2] ==5)
   {
      motor[rightside] = 30;
      motor[leftside] = 30;
   }
   wait10Msec(5000);
   {
      motor[ringlift] = -10;
      wait10Msec(2000);
   }
   motor[rightside] = -30;
   motor[leftside] = -30;
   wait10Msec(6000);
}


Best of luck!

Author:  hrazo6332 [ Sun Mar 10, 2013 11:59 pm ]
Post subject:  Re: IR seeker #include file not locating

ok thank you I'll try it

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/