View unanswered posts | View active topics It is currently Wed Sep 17, 2014 1:32 am






Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Can't connect via Bluetooth! 
Author Message
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Can't connect via Bluetooth!
Oh, yes, the problem is still here, our team has unfortunately not been focusing on the robot as of late, now its let's fund-raise till hell freezes. Oh fearless leader :poke: , don't you know that the money won't mean crap unless the robot WORKS :breakcomputer: :evil: . DUH :?

Anyways, it works under the FMS, or at least the TeleOp does, our Auto is still hinky, thus the reason I should be working on it. Possibly having something to do with the selection of the Auto code, I'm using a switch statement to do something based on the settings of three preset touch sensors that are used like binary flags to indicate the desired Auto sequence; that should work fine but at last check was misbehaving. But I digress.
It works under LabView, not that I use it though, fearless leader likes doubling the code in LabView. We haven't gone to the trouble of installing NXT-G. I may be somewhat saved though, we got a local PC repair company to donate a laptop so I may be able to use that instead of my personal one, which, until now was the primary programming platform. Of course for all I know I'll end up with the same problem though at least I won't feel so bad about doing a reinstall of Windows as a last resort. I'm still convinced it has something to do with Windows, possibly a patch or something; I say this because RobotC doesn't seem to have the deep integration with Windows necessary to mess with this and RobotC seems to be completely unrelated to the problem.

If I seem like I'm being a little long winded, I am; if only because in the minds of some this problem has gone *poof*

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Wed Mar 04, 2009 9:23 pm
Profile
Novice

Joined: Fri Oct 24, 2008 8:58 am
Posts: 87
Post Re: Can't connect via Bluetooth!
sorry to hear its not working for RobotC correctly. I don't much know what else to suggest other than reinstall everything (probably even windows).

It is a little strange that its only RobotC that's acting up. I was under the impression that they pretty much pass off most of the BT comms to the LEGO Fantom driver. So I would expect it to be pretty close to the same as FMS or LabView...maybe my understanding of this is wrong though.

If you want some help with the autonomous code, post what you have and what you think is flaky. Also I think I mentioned this before, but maybe consider using the NXT screen/buttons to select autonomous mode options instead of the switches...only a suggestion though as the switch idea should work fine.


Wed Mar 04, 2009 10:03 pm
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Can't connect via Bluetooth!
Except that it's only on my computer that RobotC is having problems, at least last I checked, that's why I'm led to believe that it's a Windows related problem, or perhaps a driver problem but I've reinstalled all the drivers I could think to be related to this. Regardless the problem persists and nothing I can think to do short of repairing Windows has fixed it; I would rather not take this route as the computer in question is the one and only family laptop and we can't afford to have it down for the six hours it would take to do the reinstall and redo all the updates which is apart from the fact that we don't have a good internet connection (I'm on someone else's wifi :twisted: , don't tell nobody (oh the irony :lol: ))...... It's not something I really want to do right now.

As for my auto problem, I haven't had much time to work on it as of late but here's what I have. In an endeavor to keep the post size down I will only put up the important parts with the assumption that some stuff can be filled in by the reader, i.e. motor definitions, etc. Note the files listed before the main program file are included (#include) in the order posted.

arm.c (only the parts referenced by the auto program)
Code:
inline void moveBucket(int position, int rate)
{
    servoChangeRate[armServo] = rate;
    servoTarget[armServo] = position;
    while(ServoValue[armServo] != position)
    {}
}
void openBucket()
{
    moveBucket(245, 0);
}

void closeBucket()
{
    moveBucket(35, 0);
}

sensorcontrol.c
Code:
//Contains functions for controlling the sensors
//Bit map definitions
#define mux_button1 0x01
#define mux_button2 0x02
#define mux_button3 0x04
#define mux_button4 0x08

bool touchMXPVal[4] = {false, false, false, false};

task getTouchMPX() //Task to get the values from the touch MUX and write true/false values to an array. Ports 1 & 2 are limit switches for the arm; ports 3 & 4 are the first 2 autonomous switches.
{
    while(true)
    {
        //Series of 4 "if" statements
        //The '&' symbol is a "logical and" used to read the bit-map from the
        //touch multiplexer.
        if(SensorValue(touchMPX) & mux_button1)//Check if pressed
            touchMXPVal[0] = true;
        else
            touchMXPVal[0] = false;

        if(SensorValue(touchMPX) & mux_button2)
            touchMXPVal[1] = true;
        else
            touchMXPVal[1] = false;

        if(SensorValue(touchMPX) & mux_button3)
            touchMXPVal[2] = true;
        else
            touchMXPVal[2] = false;

        if(SensorValue(touchMPX) & mux_button4)
            touchMXPVal[3] = true;
        else
            touchMXPVal[3] = false;

    }
}


SOTA Autonomous.c
Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////
//                                              DISCLAMER!!!!!!!
//  WARNING! This code is experimental. It is not working properly! TEST AT YOUR OWN RISK!
//  This code also contains debugging output code and sections have been commented out for the purposes of testing
//  various setups. Be wary of these. I am not responsible if your robot blows up.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Function to determine the auto switch configuration using 2 touch sensors attached to the touch MUX & a third connected to Sensor port 4 (auto3). Returns a 0 based value indicating the selected autonomous mode.
int testAuto()
{
    if(!touchMXPVal[2] && !touchMXPVal[3] && (SensorValue[auto3] == 0))
    {
        return 0;
    }
    else if(touchMXPVal[2] && !touchMXPVal[3] && (SensorValue[auto3] == 0))
    {
        return 1;
    }
    else if(!touchMXPVal[2] && touchMXPVal[3] && (SensorValue[auto3] == 0))
    {
        return 2;
    }
    else if(touchMXPVal[2] && touchMXPVal[3] && (SensorValue[auto3] == 0))
    {
        return 3;
    }
    else if(!touchMXPVal[2] && !touchMXPVal[3] && (SensorValue[auto3] == 1))
    {
        return 4;
    }
    else if(touchMXPVal[2] && !touchMXPVal[3] && (SensorValue[auto3] == 1))
    {
        return 5;
    }
    else if(!touchMXPVal[2] && touchMXPVal[3] && (SensorValue[auto3] == 1))
    {
        return 6;
    }
    else if(touchMXPVal[2] && touchMXPVal[3] && (SensorValue[auto3] == 1));
    {
        return 7;
    }
}

void initializeRobot()
{
    StartTask(getTouchMPX);
    return;
}

task main()
{
    initializeRobot();

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

    switch(testAuto()) //Based on the value returned from testAuto(), do something.
    {
    case 0:
        nxtDisplayTextLine(2, "Auto 1");
        closeBucket();
        nMotorEncoder[rightMotor] = 0;
        nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
        wait1Msec(1000);
        do
        {
            motor[leftMotor] = 100;
            motor[rightMotor] = 100;
            nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
        }while(nMotorEncoder[rightMotor] < 2500);
        motor[leftMotor] = 0;
        motor[rightMotor] = 0;
        wait1Msec(800);
        motor[leftMotor] = -80;
        motor[rightMotor] = 100;
        wait1Msec(730);
        nMotorEncoder[rightMotor] = 0;
        do
        {
            motor[leftMotor] = 100;
            motor[rightMotor] = 100;
        }while(nMotorEncoder[rightMotor] < 4000);
        motor[leftMotor] = 0;
        motor[rightMotor] = 0;
        wait1Msec(800);
        nMotorEncoder[armMotor] = 0;
        wait1Msec(200);
        /*do
        {
        motor[armMotor] = 100;
        nxtDisplayTextLine(2, "AE = %d", nMotorEncoder[armMotor]);
        }while(nMotorEncoder[armMotor] < 13000);*/
        motor[armMotor] = -100;
        wait1Msec(300);
        motor[armMotor]= 0;
        wait10Msec(10);
        //auto();
        break;
    case 1:
        nxtDisplayTextLine(2, "Auto 2");
        wait1Msec(1000);
        Turn(90);
        break;
    case 2:
        nxtDisplayTextLine(2, "Auto 3");
        break;
    case 3:
        nxtDisplayTextLine(2, "Auto 4");
        break;
    case 4:
        nxtDisplayTextLine(2, "Auto 5");
        nxtDisplayTextLine(2, "Auto 1");
        closeBucket();
        nMotorEncoder[rightMotor] = 0;
        nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
        wait1Msec(1000);
        do
        {
            motor[leftMotor] = 100;
            motor[rightMotor] = 100;
            nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
        }while(nMotorEncoder[rightMotor] < 2500);
        motor[leftMotor] = 0;
        motor[rightMotor] = 0;
        wait1Msec(800);
        motor[leftMotor] = 100;
        motor[rightMotor] = -80;
        wait1Msec(730);
        nMotorEncoder[rightMotor] = 0;
        do
        {
            motor[leftMotor] = 100;
            motor[rightMotor] = 100;
        }while(nMotorEncoder[rightMotor] < 4000);
        motor[leftMotor] = 0;
        motor[rightMotor] = 0;
        wait1Msec(800);
        nMotorEncoder[armMotor] = 0;
        wait1Msec(200);
        /*do
        {
        motor[armMotor] = 100;
        nxtDisplayTextLine(2, "AE = %d", nMotorEncoder[armMotor]);
        }while(nMotorEncoder[armMotor] < 13000);*/
        motor[armMotor] = -100;
        wait1Msec(300);
        motor[armMotor]= 0;
        wait10Msec(10);
        //auto();
        break;
    case 5:
        nxtDisplayTextLine(2, "Auto 6");
        break;
    case 6:
        nxtDisplayTextLine(2, "Auto 7");
        break;
    case 7:
        nxtDisplayTextLine(2, "Auto 8");
        break;
    }
}


While I put the disclamer in there as a bit of a joke :D , this is experimental and there are some sections that have been commented out either because I wanted to do something else but perhaps return to the idea or I couldn't get it to work so I put in something else but didn't want to delete the problem. :bigthumb:

Have at it fellas, I appreciate your thoughts. Just know that we're probably not going to change our set up for selecting the mode though if you have any thoughts on it post them, we may use them in future :D ; and if anyone knows what the hell is going on with the Bluetooth thing, POST IT! :!: :!: :poke:

Arigato gozaimasu (Thank you very much).

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Sun Mar 08, 2009 12:28 am
Profile
Novice

Joined: Fri Oct 24, 2008 8:58 am
Posts: 87
Post Re: Can't connect via Bluetooth!
Doitashimaste.

so now that we see the code, can you describe a little what its not doing correctly?


Mon Mar 09, 2009 9:32 am
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Can't connect via Bluetooth!
Actually it's domo arigato gozaimashita.

Well for starters, at our competition, mind you this was pre-templates, the first one in fact, it refused to start during the software inspection, which was really just a, "Can you connect? Do the two sections run?" sort of deal. We decided to jsut fly without it as we didn't really have anything useful.

Now however, I can get it to run under the templates and the FMS, sort of. It does what I've told it to do but it dosen't wait for the go signal. As is necessary under the FMS you run the program from the NXT and then the FMS starts the match, allowing the code to proceed. When I run the program the wheels on one side just start running, this is not programmed, then the code sequence starts as specified, runs and then I believe it starts over again, mind you the last time I looked at this was a month ago so I'm not sure.

Now as per the code, it should start the task for the MUX then wait till the go signal is given at which point the function to determine the touch switch settings in called as the argument to the switch statement at which point it should test the value and then pick the appropriate code block. The break statements prevent it from continuing to the next block. Once the code has run its course it should terminate.

So what, in your (plural) opinions is the problem. :poke: :?:

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Mon Mar 09, 2009 9:00 pm
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Can't connect via Bluetooth!
Well, I have solved the part of the problem which involves the wheels on one side spinning. I changed the initilizeRobot function, thusly:
Code:
void initializeRobot()
{
    StartTask(getTouchMPX);
    openBucket();
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    return;
}

I am still having some problems with the auto mode selection though.

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Thu Mar 12, 2009 9:32 pm
Profile
Novice

Joined: Mon Oct 13, 2008 6:29 pm
Posts: 75
Location: Florida, USA
Post Re: Can't connect via Bluetooth!
I know that this may not be an ideal solution, but try just having multiple autonimous programs like REDRAMP,BLUERAMP, etc. we did this and had no problems

_________________
PHUHS Robotics
Team 516 FTW

Daytona Robofest Winning Alliance Captain
Daytona Robofest Inspire Award


Fri Mar 20, 2009 5:24 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 22 posts ]  Go to page Previous  1, 2

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.