View unanswered posts | View active topics It is currently Thu Oct 02, 2014 10:35 am






Reply to topic  [ 4 posts ] 
Compass instruccion not working 
Author Message
Rookie

Joined: Mon Feb 03, 2014 3:00 am
Posts: 2
Post Compass instruccion not working
We have been testing Compass examples, none seem to work properly. Either the robot won't move or turn endlessly. Any insights?


Mon Feb 03, 2014 3:04 am
Profile
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: Compass instruccion not working
Hi agonzalez,
Only very old virtual worlds have robots equipped with compasses. Modern virtual robots instead use gyroscopes to measure turning. All modern virtual worlds also include a screen where you can see all the motors and sensors that are on each robot - check it out to see which sensors you have available to program with.

Best,
--Ryan

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Mon Feb 03, 2014 1:22 pm
Profile
Rookie

Joined: Mon Feb 03, 2014 3:00 am
Posts: 2
Post Re: Compass instruccion not working
We are using Operation Reset. The version that is been on the website for the past month.
The robot shows a Compass Sensor on Digital Port 5.
Even when this VW is old, shouldn't it work? We are using Natural Language and the samples that came with the program.
Should I try to change them to gyroscope? Would it take it?

Thanks for your help


Mon Feb 03, 2014 2:15 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: Compass instruccion not working
Just checked, and that was an oversight on our part. Yes, the Operation Reset robots are still using the compass.

Try this updated code. It's the Turning with Compass sample code with two changes: I had to increase the amount of power being sent to the motors, and I had to reverse the rightMotor. We'll make sure these changes are included with the next release of ROBOTC
Code:
#pragma config(Sensor, in1,    leftLineFollower, sensorLineFollower)
#pragma config(Sensor, in2,    centerLineFollower, sensorLineFollower)
#pragma config(Sensor, in3,    rightLineFollower, sensorLineFollower)
#pragma config(Sensor, dgtl1,  rightEncoder,   sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  leftEncoder,    sensorQuadEncoder)
#pragma config(Sensor, dgtl5,  compassSensor,  sensorVirtualCompass)
#pragma config(Sensor, dgtl6,  touchSensor,    sensorTouch)
#pragma config(Sensor, dgtl8,  sonarSensor,    sensorSONAR_cm)
#pragma config(Motor,  port2,           rightMotor,    tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard


/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Turning with Compass
This program instructs your robot turn until the desired number of degrees has been reached.
There is a two second pause at the beginning of the program.

Robot Model(s): Squarebot

[I/O Port]          [Name]              [Type]                [Description]
Motor Port 2        rightMotor          VEX Motor             Right side motor
Motor Port 3        leftMotor           VEX Motor             Left side motor
Digital Port 5      compassSensor       Compass

*To run this sample program on Swervebot, be sure to Reverse Motor Port 3 in the Motors and Sensors
 Setup, and to make sure that Motor Port 2 is NOT Reversed.
----------------------------------------------------------------------------------------------------*/

// This program turns right for a specified 'degrees'

task main()
{
  wait1Msec(2000);
  int degrees = 90;                     // 'degrees' is how many degrees we want to turn

  int goal = (SensorValue[compassSensor] + degrees) % 360;  // 'goal' is be the current compassSensor reading + our turning degrees
                                                      /* We have to use modulus 360 to keep our goal within the bounds   */
                                                      /* of the compassSensor (1 to 360 degrees, 0 is 360).                    */

  while(SensorValue[compassSensor] != goal)   // while the compassSensor sensor reading is not yet our goal:
  {
                              // turn RIGHT in place (point turn):
    motor[rightMotor] = 30;              // set port2 to speed -15
    motor[leftMotor]  = 30;               // set port3 to speed 15
  }
                                        // stop the robot:
  motor[rightMotor] = 0;                // set port2 to speed 0
  motor[leftMotor]  = 0;                // set port3 to speed 0
}

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Mon Feb 03, 2014 9:35 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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:  



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