View unanswered posts | View active topics It is currently Fri Jul 25, 2014 12:29 pm






Reply to topic  [ 4 posts ] 
Seeing eye robot 
Author Message
Rookie

Joined: Tue Nov 05, 2013 12:21 pm
Posts: 8
Post Seeing eye robot
Hi,

I am beginner programmer and i would was browsing your wiki, and found a very nice tutorial on the seeing eye dog.
My question is can is it possible to modify the program to run on Bluetooth instead of the bee attachment?

tutorial location

http://www.robotc.net/firewiki/index.php?title=Seeing_Eye_Robot

Code:
#pragma config(Sensor, S3,     sonar3,              sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
 
// Robot A  - move through obstacle course using sensors (1 corner version)
// Send commands to Robot B (no sensors) to follow Robot A
// 1) move fwd using sonar; stop at wall
// 2) create commmand string for RobotB
// 3) turn right
// 4) create commmand string for Robot B
// 5) move 2 feet out out obstacle course, then stop
// 6) create commmand string for Robot B (avoid collision)
// 7) send each command to Robot B and wait for response before sending next cmd
 
#include "XbeeTools.h"
 
task main()
{
  InitRS485();
 
  string messageReceived;
 
  wait1Msec(2000);  // avoid having hand blocking sonar
 
// 1) move fwd using sonar; stop at wall
  nMotorEncoder[motorB] = 0;
 
  while (SensorValue[sonar3] > 30)  // move fwd until wall
  {
    motor[motorB] = 50;
    motor[motorC] = 50;
  }
 
  motor[motorB] = 0;  // stop robot
  motor[motorC] = 0;
  wait1Msec(200);
 
  // 2) create commmand string for RobotB
  int count = nMotorEncoder[motorB];
  string messageToSend1;
  StringFormat(messageToSend1, "Fwd%d", count+500);  // RobotB starts behind RobotA
 
 
  // 3) turn right
 
  nMotorEncoder[motorC] = 0;
 
  while (nMotorEncoder[motorC] < 160)
  {
    motor[motorB] = -50;
    motor[motorC] = 50;
  }
 
  motor[motorB] = 0;  // stop robot
  motor[motorC] = 0;
  wait1Msec(200);
 
  // 4) create commmand string for RobotB
  string messageToSend2 = "TurnR";
 
 
 
  // 5) move 2 feet out out obstacle course
 
  nMotorEncoder[motorB] = 0;
  while (nMotorEncoder[motorB] < 1500)
  {
    motor[motorB] = 50;
    motor[motorC] = 50;
  }
   motor[motorB] = 0;  // stop robot
   motor[motorC] = 0;
   wait1Msec(200);
 
   //6) create commmand string for RobotB
 
   string messageToSend3 = "Fwd800";  // avoid collision
 
 
  // 7) send commands sequentially to RobotB
  // Wait for response from RobotB that command has been completed
  // before sending next command
 
  SendString(messageToSend1);       // send command to RobotB to move forward
  ReceiveString(messageReceived);   // wait until RobotB has indicated it has completed task
  PlayTone(200, 20);
 
  SendString(messageToSend2);       // send command to RobotB to turn right
  ReceiveString(messageReceived);   // wait until RobotB has indicated it has completed task
  PlayTone(200, 20);
 
  SendString(messageToSend3);       // send command to RobotB to move forward
  ReceiveString(messageReceived);   // wait until RobotB has indicated it has completed task
  PlayTone(200, 20);
 
 
}
 



Code:
// Leader-Follower  Lab -  Robot B (1 corner version)
#include "XbeeTools.h"
 
task main()
{
  InitRS485();
 
  string messageReceived;
  int count;
 
  while(true)
  {
          ReceiveString(messageReceived);  // wait for commands from Robot A
 
          nxtDisplayString(1, "A Said:%s", messageReceived);
 
          if (StringFind(messageReceived, "Fwd") >= 0)
          {
            StringDelete(messageReceived, 0, 3);
            count = atoi(messageReceived);
 
            nMotorEncoder[motorB] = 0;
 
            while ( nMotorEncoder[motorB] < count)  // move fwd until blk line
            {
             motor[motorB] = 50;
             motor[motorC] = 50;
            }
 
            motor[motorB] = 0;  // stop robot
            motor[motorC] = 0;
 
            SendString("Done");  // report back to Robot A
          }
 
 
          else if (StringFind(messageReceived, "TurnR") >= 0)
          {
            nMotorEncoder[motorC] = 0;
 
                  while (nMotorEncoder[motorC] < 165)
                  {
                    motor[motorB] = -50;
                    motor[motorC] = 50;
                  }
 
                  motor[motorB] = 0;  // stop robot
                  motor[motorC] = 0;
 
                  SendString("Done");  // report back to Robot A
          }
 
  }
 
}
 


Tue Nov 05, 2013 12:32 pm
Profile
Rookie

Joined: Thu Nov 07, 2013 5:58 am
Posts: 1
Post Re: Seeing eye robot
This code helps me out perfectly...!


Thu Nov 07, 2013 6:25 am
Profile
Rookie

Joined: Tue Nov 05, 2013 12:21 pm
Posts: 8
Post Re: Seeing eye robot
Owen Wilson wrote:
This code helps me out perfectly...!



Glad, but my problem is still not resolved any help?


Thu Nov 07, 2013 12:04 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Seeing eye robot
f6e9a wrote:
Glad, but my problem is still not resolved any help?

Probably a spammer, actually. Quite common on these forums. I don't actually know what they're advertising...
Ontopic: I have no clue. Never worked with Bluetooth. Sorry.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Thu Nov 07, 2013 10:10 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:  
cron



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