View unanswered posts | View active topics It is currently Sat Aug 23, 2014 6:13 am






Reply to topic  [ 10 posts ] 
BlueTooth Woes (RobotC Edition!) 
Author Message
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post BlueTooth Woes (RobotC Edition!)
I have the following two programs:

Code:
#pragma config(Sensor, S1, ColorSens, sensorCOLORFULL)
#pragma config(Sensor, S2, ArmRst, sensorTouch)
#pragma config(Motor, motorB, ArmTurnMtr, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, ArmMoveMtr, tmotorNormal, PIDControl, encoder)

void initialize();

const int DegreesToLoc[] = {1,2,3,4,5,6};

const ubyte IsConnected[] = {1};
const ubyte IAmConnected[] = {2};

ubyte SentMessage;

task main()
{
  initialize();
}

void initialize()
{
  btConnect(1, "Slave");
  cCmdMessageWriteToBluetooth(IsConnected[0], 1, 0);
  while(cCmdMessageRead(SentMessage, 1, 0) != IAmConnected[0]);

  motor[ArmMoveMtr] = -30;
  while(SensorValue(ArmRst) == 0);//94 1062
  motor[ArmMoveMtr] = 0;

  motor[ArmTurnMtr] = -30;
  while(motorPWMLevel[ArmTurnMtr] >= -55);
  motor[ArmTurnMtr] = 0;

  nMotorEncoder[ArmTurnMtr] = 0;
  nMotorEncoderTarget[ArmTurnMtr] = 94;
  motor[ArmTurnMtr] = 20;
  while(nMotorRunState[ArmTurnMtr] != runStateIdle);
  motor[ArmTurnMtr] = 0;

  nMotorEncoder[ArmMoveMtr] = 0;
  nMotorEncoderTarget[ArmMoveMtr] = 1062;
  motor[ArmMoveMtr] = 100;
  while(nMotorRunState[ArmMoveMtr] != runStateIdle);
  motor[ArmMoveMtr] = 0;
}


And:

Code:
#pragma config(Sensor, S1, NoBttn, sensorTouch)
#pragma config(Sensor, S2, YesBttn, sensorTouch)
#pragma config(Sensor, S3, LightSens, sensorLightInactive)
#pragma config(Sensor, S4, HTIRL, sensorI2CCustom)
#pragma config(Motor, motorC, TumblrMtr, tmotorNormal, PIDControl, reversed, encoder)

#include "drivers/HTIRL-driver.h";

void initialize();

const ubyte IsConnected[1] = {1};
const ubyte IAmConnected[1] = {2};

ubyte SentMessage;

tPFmotor Tread1AndLights = pfmotor_S4_C1_A;
tPFmotor Tread2 = pfmotor_S4_C1_B;
tPFmotor DispenserMtr = pfmotor_S4_C2_A;
tPFmotor PneumSwtch = pfmotor_S4_C2_B;
tPFmotor BrickScannerDisp = pfmotor_S4_C3_A;
tPFmotor ColorScanAlign = pfmotor_S4_C3_B;

task main()
{
  initialize();
}

void initialize()
{
  while(cCmdMessageRead(SentMessage, 1, 0) != IsConnected[0]);
  cCmdMessageWriteToBluetooth(IAmConnected[0], 1, 0);
}


When I run the programs, the bricks connect, the Master sends the message to the Slave, the "SentMessage" variable on the Slave turns to "1", but it doesn't send the Master the reply :breakcomputer: . It seems to me like it should work, but then again this is the first time I'm using BlueTooth :oops: .

This probably isn't the best way to do it, and I'm VERY open to suggestions :poke: .

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sun Feb 19, 2012 2:22 am
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: BlueTooth Woes (RobotC Edition!)
Anyone? Please? :cry:

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sun Feb 19, 2012 12:53 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: BlueTooth Woes (RobotC Edition!)
ARRGHHHHH!!!! Now I've figured it out!!! And it was so simple!!!!!!! :breakcomputer: :breakcomputer: :breakcomputer: :crying: :crying: :crying: :crying: :evil: :evil: :evil: :evil: :downloading:

I've spent two days doing nothing and the answer was right in front of me!!!!! AAAAAAAAAAAAAAAAAAAA!!!!!!!!!

Please exscuse the tyraniccal rant. I just have a tight deadline for this project, and can't afford this kind of delay :wink: . Now back to your regularly scheduled programming.

:x :x :x :breakcomputer: :breakcomputer: :eek: :cry: :evil: :evil: :cry: :(

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Feb 21, 2012 12:56 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: BlueTooth Woes (RobotC Edition!)
If you've figured out the solution to your problem, then perhaps you could post it here? That way, others with similar problems wont have to "spend two days doing nothing".

_________________
sudo rm -rf /


Tue Feb 21, 2012 1:37 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3192
Location: Rotterdam, The Netherlands
Post Re: BlueTooth Woes (RobotC Edition!)
Yup, fess up your sins! If not for helping others, at least allow us to be entertained! Perhaps then I will tell you the story of how I wasted a weekend figuring out why I thought my compass module was broken, when it clearly wasn't.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Feb 21, 2012 1:44 am
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: BlueTooth Woes (RobotC Edition!)
Talking about entertained, I can share a story. This story is about our FRC robot, not FTC but entertaining nevertheless. Our FRC student couldn't get the servo to work, so he asked me to help him figure out what's wrong. I tried hooking up to a second servo, replacing the servo wire, even scope the sevo wire and saw nothing, and ten million other things and half hour later, couldn't understand why nothing works. Then I asked the student to try moving another motor. It didn't work either. In fact, nothing on the robot works. Then it dawned on him that since we were working on two robots: one for competition, one for testing software and he was working on the test bot before got dragged to test the servo on the competition robot that he forgot his laptop was still connected to the test bot. So we were commanding the test bot upstair through wireless the whole time while we were trying to debug the competition robot. Luckily the test bot upstair was sitting on two 2x4 off the ground or it might be running wild without us noticing.


Tue Feb 21, 2012 8:31 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: BlueTooth Woes (RobotC Edition!)
Okay! I was going to yesterday, but I was forced to go to bed. Anyway, my problem was: I thought that checking this:
Code:
while(cCmdMessageRead(SentMessage, 1, 0) != IsConnected[0]);

Was seeing if the contents of the message was not equal to my variable. However, it wasn't.
It WAS receiving the message, but it wasn't actually comparing it to anything!
Here is the fixed code.
Code:
while(SentMessage[0] != IsConnected[0]){cCmdMessageRead(SentMessage, 1, 0)}


mightor wrote:
Yup, fess up your sins! If not for helping others, at least allow us to be entertained! Perhaps then I will tell you the story of how I wasted a weekend figuring out why I thought my compass module was broken, when it clearly wasn't.

- Xander


Not funny enough for ya? Okay then, here's something: When I figured it out, I couldn't decide whether I wanted to woop with joy, or kick myself! :lol: :lol: Then it just seemed so obvious!! :poke: :poke:

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Feb 21, 2012 10:18 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3192
Location: Rotterdam, The Netherlands
Post Re: BlueTooth Woes (RobotC Edition!)
I spent 2 days trying to figure out why my dCompass wasn't working properly. I kept getting very weird readings that made no sense at all. First I thought it was my maths but that checked out. Then I tried NXT-G and NXC, with various firmwares, still the weird errors. I thought that I had broken my sensor during one of the many times I transport my stuff from one NXT demo to another. The code worked fine when John from Dexter Industries tested it so we both thought that the sensor was broken. So after a little conversation with Aswin, who also tested the code, etc, etc, I showed him a picture of my setup:
Attachment:
IMAG0308.jpg
IMAG0308.jpg [ 56.53 KiB | Viewed 1946 times ]

He said "Oh no wonder, it's too close to the brick." So I took it off my little frame, placed it about 10 cms from the brick and it all worked like a charm.

Turns out magnetic compasses are sensitive to magnetic fields. Who would've thought?

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Feb 21, 2012 1:01 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: BlueTooth Woes (RobotC Edition!)
mightor wrote:
I spent 2 days trying to figure out why my dCompass wasn't working properly. I kept getting very weird readings that made no sense at all. First I thought it was my maths but that checked out. Then I tried NXT-G and NXC, with various firmwares, still the weird errors. I thought that I had broken my sensor during one of the many times I transport my stuff from one NXT demo to another. The code worked fine when John from Dexter Industries tested it so we both thought that the sensor was broken. So after a little conversation with Aswin, who also tested the code, etc, etc, I showed him a picture of my setup:
Attachment:
IMAG0308.jpg

He said "Oh no wonder, it's too close to the brick." So I took it off my little frame, placed it about 10 cms from the brick and it all worked like a charm.

Turns out magnetic compasses are sensitive to magnetic fields. Who would've thought?

- Xander


I would have thought!!! Eventually. It would probably end up being the same as this problem. Agonizing over it, and then have an "eureka!" moment where you figure it out, but feel you should have seen it much sooner. That's actually how quite a few of my problems have been solved.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Last edited by NeXT-Generation on Tue Feb 21, 2012 5:52 pm, edited 1 time in total.



Tue Feb 21, 2012 1:51 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: BlueTooth Woes (RobotC Edition!)
One of the programmers on my team spent hours upon hours trying to get ROBOTC to install and run. She had been working with ROBOTC for two years, so we were all confidant in her ability to get it up and running. When it just wouldn't happen, She finally showed it to the rest of the team, hoping that someone could fix it. After about 5 seconds, we all looked at her like -_- Turns out that she was trying to execute the .exe file in Ubuntu.

_________________
sudo rm -rf /


Tue Feb 21, 2012 5:43 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 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.