View unanswered posts | View active topics It is currently Sat Oct 25, 2014 7:56 pm






Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Trying to get Sonar Sensor to work on Autonomous 
Author Message
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
We are still having some problems on the sonar sensor. :programmer: Me and max are still trying to figure out why it would see the wall in autonomus. If you have any idea what is going on tell me thanks. :breakcomputer:

:poke:
Dtrain3455


Wed Nov 09, 2011 10:06 am
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
Did you put a nxtDisplayTextLine statement in the code to display the reading of the sonar sensor? This is to make sure the sonar sensor does give you sensible values.


Wed Nov 09, 2011 2:26 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
We just took the whole robot apart and are starting fresh. We will have to redo the mounting on the Sonar sensor among other things. I think that we didn't put that in the code, but we're a bit busy trying to put a passable robot together. o.0 It's really grating on my nerves, as I am tasked with rebuilding the crate-flinging, shoulder-slamming, mentor-killing arm thing so that the motor doesn't burn out just lifting it... Thank you for the reminder, however. I will add it to the programming later.

Maximilian

I'm building :twisted:


Wed Nov 09, 2011 4:11 pm
Profile WWW
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
Good luck!


Fri Nov 11, 2011 1:55 pm
Profile WWW
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
Well, our mentor decided to take apart the robot AGAIN, so we're starting to rebuild it. The omni wheels have a tough time getting up the ramp, and the normal wheels have a tough time turning the robot. We're working it out, but it's hard to get a program together when the builders are always changing the orientation of the motors, servos and other electronic stuff on the robot.


Thu Nov 17, 2011 10:56 am
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
dtrain34555 wrote:
The omni wheels have a tough time getting up the ramp, and the normal wheels have a tough time turning the robot.

That's why we are using regular wheels as the back wheels and omni's as the front wheels. The back wheels still give you enough traction to push the bowling ball up the ramp and the front omni's make it easier to turn.


Thu Nov 17, 2011 2:13 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
We had a halftrack design with omni wheels in the front, not all four omni wheels:) That wouldn't have worked too well... We're going with a different halftrack design now. I hope it works; the programming is getting to be a headache, as I'm the only experienced programmer on this team. Btw, our school has three teams, and I have been acting as mentor to the rookie team for a long time. It was pretty cool when they found a way to clean up my original TeleOp, and I'm basing my program on their edited version! I guess I've kinda gotten into a programming rut... :)

Maximilian


Thu Nov 17, 2011 4:57 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
In theory, you can structure the program such that changing drive train should not be too much of a hassle to change the program to match. As long as your are still "two-motor-drive", all you need to change are the mappings of the left and right motors (in the pragmas) and whether one motor is "reversed" or not. If you also change the gear ratio or wheel sizes, you may need to recalibrate your PID controlled drive (distance to encoder click translation). We define all those as constants in a file called "RobotInfo.h". So it is a matter of changing numbers in that file.


Thu Nov 17, 2011 5:14 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
That wasn't what I was saying... I was saying that with the Omni wheels, it was hard to get up the ramp. It kept sliding to the side. It's not really a problem to re-write TeleOp, it's a matter of what we are using to get around the field. Sorry for the confusion...
Maximilian


Thu Nov 17, 2011 5:42 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
dtrain34555 wrote:
but it's hard to get a program together when the builders are always changing the orientation of the motors, servos and other electronic stuff on the robot.

Sorry I was commenting on the comment in your previous post.


Thu Nov 17, 2011 6:08 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
I am trying to get the magnet sensor to dectect somthing when it sees 700. I am still trying to look into it. if you can help thanks







#pragma config(Sensor, S2, magnetSensor, sensorHiTechnicMagnetic)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

//Deviation/Proximity of the Magnet Determines this value
#define threshold 200

//Value of the sensor when nothing is detected
#define NoMagnetValue 650

//Value od the sensor when somthing is detected
#define MagnetValue 700

task main()
{
while(true)
{
nxtDisplayTextLine(1, "Magnet: %d", SensorValue[magnetSensor]);

if(SensorValue[magnetSensor] > (NoMagnetValue + threshold))
{
nxtDisplayTextLine(3, "Magnet(NorthTop)");
}
else if(SensorValue[magnetSensor] < (NoMagnetValue - threshold))
{
nxtDisplayTextLine(3, "Magnet(SouthTop)");
}
else
{
nxtDisplayTextLine(3, "Nothing Detected");
}
wait1Msec(25);
}
}


Sat Nov 19, 2011 12:32 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
Did you try Xander's sample code and driver? HTMAG-test1.c and HTMAG-driver.c? If that works, you can write your code based on the sample code.


Sat Nov 19, 2011 2:08 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
We already got it to work. Thank you for the help! We'll keep you posted if we have any other programming issues.

Team 4296: The Disco Demons

Maximilian

P.S. What does "disco demons" have to do with robotics? I haven't been able to figure that out... I had little say in the team name.


Sat Nov 19, 2011 2:17 pm
Profile WWW
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
Here's our program as of yet:

#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
#pragma config(Sensor, S2, magnetSensor, sensorHiTechnicMagnetic)
#pragma config(Sensor, S3, touchSensor, sensorTouch)
#pragma config(Sensor, S4, IRSensor, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop)
#pragma config(Servo, srvo_S1_C3_1, servo1, tServoStandard)
#pragma config(Servo, srvo_S1_C3_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C3_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C3_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C3_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C3_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

//Deviation/Proximity of the Magnet Determines this value
#define MAGNET_THRESHOLD 5

//Value of the sensor when nothing is detected
#define NO_MAGNET_VALUE 654

//Value of the sensor when somthing is detected
#define MAGNET_VALUE 660

task main()
{
const int threshold = 20; /* Int 'threshold' will allow us to ignore low */
/* readings that keep our robot in perpetual motion. */
while(true)
{
getJoystickSettings(joystick);
// -- Control Motor D
if(abs(joystick.joy1_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorD] = joystick.joy1_y1; // Motor D is assigned a power level equal to the left analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorD] = 0; // Motor D is stopped with a power level of 0.
}

// -- Control Motor E
if(abs(joystick.joy1_y2) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorE] = joystick.joy1_y2; // Motor E is assigned a power level equal to the right analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorE] = 0; // Motor E is stopped with a power level of 0.
}

// -- Control Motor G
if(abs(joystick.joy2_y1) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorG] = joystick.joy2_y2; // Motor G is assigned a power level equal to the right analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorG] = 0; // Motor G is stopped with a power level of 0.
}

// -- Control Motor F
if(abs(joystick.joy2_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorF] = joystick.joy2_y1; // Motor F is assigned a power level equal to the left analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorF] = 0; // Motor F is stopped with a power level of 0.
}

/////////////////////////////////////////////////////////////////
// -- Control Magnet Sensor
/////////////////////////////////////////////////////////////////
nxtDisplayTextLine(1, "Magnet: %d", SensorValue[magnetSensor]); // display magnet sensor value

if(SensorValue[magnetSensor] > (NO_MAGNET_VALUE + MAGNET_THRESHOLD))
{
nxtDisplayTextLine(3, "Magnet(NorthTop)");
}
else if(SensorValue[magnetSensor] < (NO_MAGNET_VALUE - MAGNET_THRESHOLD))
{
nxtDisplayTextLine(3, "Magnet(SouthTop)");
}
else
{
nxtDisplayTextLine(3, "Nothing Detected");
}
//wait1Msec(25);
}

if(SensorValue[magnetSensor] > (NO_MAGNET_VALUE + MAGNET_THRESHOLD) || SensorValue[magnetSensor] < (NO_MAGNET_VALUE - MAGNET_THRESHOLD))

{
servo[servo1] = 0;
}
if(SensorValue[touchSensor] == 1)
{
servo[servo1] = 90;
}

return;}

We still need to program the IR beacon into the Autonomous, and we'll need help there, but here's our TeleOp. How is it? :bigthumb: :D

Maximilian


Sat Nov 19, 2011 3:03 pm
Profile WWW
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
Here's our Autonomous:

#pragma config(Hubs, S1, HTMotor, HTServo, HTMotor, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, sonarSensor, sensorSONAR)
#pragma config(Sensor, S3, lightSensor, sensorLightActive)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C3_1, motorF, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C3_2, motorG, tmotorNormal, openLoop, reversed)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoStandard)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoContinuousRotation)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Mode Code Template
//
// This file contains a template for simplified creation of an autonomous program for an Tetrix robot
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// initializeRobot
//
// Prior to the start of autonomous mode, you may want to perform some initialization on your robot.
// Things that might be performed during initialization include:
// 1. Move motors and servos to a preset position.
// 2. Some sensor types take a short while to reach stable values during which time it is best that
// robot is not moving. For example, gyro sensor needs a few seconds to obtain the background
// "bias" value.
//
// In many cases, you may not have to add any code to this function and it will remain "empty".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

void initializeRobot()
{
servo[servo2] = 240; // Place code here to sinitialize servos to starting positions.
// Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.
servo[servo1] = 200;
return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main Task
//
// The following is the main code for the autonomous robot operation. Customize as appropriate for
// your specific robot.
//
// The types of things you might do during the autonomous phase (for the 2008-9 FTC competition)
// are:
//
// 1. Have the robot follow a line on the game field until it reaches one of the puck storage
// areas.
// 2. Load pucks into the robot from the storage bin.
// 3. Stop the robot and wait for autonomous phase to end.
//
// This simple template does nothing except play a periodic tone every few seconds.
//
// At the end of the autonomous period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

task main()
{
initializeRobot();

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

//
// Move forward until 15 cm from the wall.
//
while (SensorValue(sonarSensor) > 15)
{
nxtDisplayTextLine(3, "sonar=%d", SensorValue(sonarSensor));
motor[motorD] = 100;
motor[motorE] = 100;
EndTimeSlice();
}

//
// Turn for half a second
//
motor[motorD] = -60;
motor[motorE] = 60;
wait1Msec(500);

//
// Go forward for 2 seconds.
//
motor[motorD] = 50;
motor[motorE] = 50;
wait1Msec(2000);

//
// Turn for 1 second.
//
motor[motorD] = -80;
motor[motorE] = 80;
wait1Msec(1000);

//
// Move forward for 5.5 seconds.
//
motor[motorD] = 80;
motor[motorE] = 80;
wait1Msec(5500);

//
// Stop!
//
motor[motorD] = 0; //Stop 'rightmotor'.
motor[motorE] = 0; //Stop 'leftmotor'.
}


We need it to track the IR beacon. Can you help us with that? Also, I can't figure out if we're supposed to use IRSeeker600 or 1200. Thanks!

Maximilian (Max)


Sat Nov 19, 2011 3:20 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

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.