View unanswered posts | View active topics It is currently Mon Dec 22, 2014 10:16 am






Reply to topic  [ 3 posts ] 
Need help on my code 
Author Message
Rookie

Joined: Mon Jun 24, 2013 5:15 pm
Posts: 16
Post Need help on my code
Hi, i was trying to do some stuff similar to 6/24's lesson today. i want the robot to continue going in the same direction even if you pick it up and move it. I am trying to get the gyro sensor to track the change in direction and right its self. heres my code along with is errors (at the bottom) i put @ where the errors are. any thouhts?? :?:


Code:
#pragma config(Sensor, S1,     HTGYRO,              sensorAnalogInactive)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


 @  #include "drivers/hitechnic-gyro.h"  @

task main ()
{
   float rotSpeed = 0;
   float heading = 0;

   // Calibrate the gyro, make sure you hold the sensor still
 @   HTGYROstartCal(HTGYRO);   @

   // Reset the timer.
   time1[T1] = 0;

   while (true)
   {
      // Wait until 20ms has passed
      while (time1[T1] < 20)
         wait1Msec(1);

      // Reset the timer
      time1[T1]=0;

      // Read the current rotation speed
        @     rotSpeed = HTGYROreadRot(HTGYRO);   @

      // Calculate the new heading by adding the amount of degrees
      // we've turned in the last 20ms
      // If our current rate of rotation is 100 degrees/second,
      // then we will have turned 100 * (20/1000) = 2 degrees since
      // the last time we measured.
      heading += rotSpeed * 0.02;

      //display value of gyro
      nxtDisplayCenteredBigTextLine(3, "%2.0f", heading);
      // move tword the direction first pointing

      while(true)
      {
         while(SensorValue(HTGYRO) == 0 || SensorValue(HTGYRO) == -0)
         {
            motor[motorB] = 80; //forward
            motor[motorC] = 80;
         }
         while(SensorValue(HTGYRO) < 0 || SensorValue(HTGYRO) < -0)
         {
            motor[motorB] = -80; //right
            motor[motorC] = 80;
         }
         while(SensorValue(HTGYRO) > 0 || SensorValue(HTGYRO) > -0)
         {
            motor[motorB] = 80;  //left
            motor[motorC] = -80;
         }
      }

   }
}

errors:
**Severe*:Couldn't open '#include' file 'drivers/hitechnic-gyro.h'
**Error**:Undefined procedure 'HTGYROstartCal'.
**Error**:Too many parameters specified. Call to 'HTGYROstartCal'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'.
**Error**:Undefined procedure 'HTGYROreadRot'.
**Error**:Too many parameters specified. Call to 'HTGYROreadRot'. Parameter: 'N/A' is 'HTGYRO' of type 'tSensors'.


Last edited by dwarf9668 on Mon Jun 24, 2013 5:51 pm, edited 1 time in total.



Mon Jun 24, 2013 5:28 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: Need help on my code
The HiTechnic Gyro driver is included in the 3rd Party Sensor Drivers sample code package, not the main ROBOTC libraries. Changing the include line to
Code:
#include "../Sample Programs/NXT/3rd Party Sensor Drivers/drivers/hitechnic-gyro.h"

worked for me. Alternately, you can copy hitechnic-gyro.h and common.h from the same location in the sample programs into the folder where your code is saved and do
Code:
#include "hitechnic-gyro.h"


Cheers,
--Ryan

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Mon Jun 24, 2013 5:40 pm
Profile
Rookie

Joined: Mon Jun 24, 2013 5:15 pm
Posts: 16
Post Re: Need help on my code
Thanks a lot it really helped. IT COMPILED COMPLETELY!!! YOU RULE! THANKS

keep digin holes, Dwarf9668


Mon Jun 24, 2013 5:52 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.