View unanswered posts | View active topics It is currently Tue Jun 28, 2016 9:30 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Issues with Autonomous Code
Author Message
Rookie

Joined: Fri Feb 10, 2012 9:07 pm
Posts: 2
Issues with Autonomous Code
Hello, im new to both the forums and using ROBOTC. I am in a competition in college where we have to build and program an NXT robot to do the following:

1) Avoid obstacles
2) Find objects, small canisters, and tell whether they are trash(dont beep) or nuclear(beep)
3) Take the trash to the corner with a bright light(got this down perfect)
4) Take the nuclear canister to the corner across from the light corner

So I began with just a simple go forward until touch sensor is pressed finding strategy, but once I tried to alter the code to include a turn in while loop, the robot doesnt seem to notice there is a canister in its claw, or at least doesnt for awhile. I know the while condition isnt assesed until after the statement is run, but is there any way i can have it always checking for the canister and keep going 3 feet forward and then turn 195 degrees?

 Code:while( SensorValue[touch] == 0 ) {        // While there is nothing in the claw, keep on moving        motor[Left] = 80;                               motor[Right] = 80;        wait10Msec(2000);                motor[Left] = 20;                       // Turn        motor[Right] = 65;        wait1Msec(1950);      }            motor[Left] = 0;      motor[Right] = 0;

Also, in developing the code to find the nuclear deposit zone, I ran into some issues because one simply cant have the robot find the light corner and then turn 180 degrees and go forward for awhile bc the canisters can be placed anywhere on the field and thus the robot can be at various different angles in respect to the light source. My idea was to have the robot find the light, then slowly turn and as it turns, take in values using the ultrasonic sensor to determine where it is in terms of cardinal directions. So having lots of 'leftwall = true', 'bottomwall = false' type of statements. If you have any ideas or hints that would be wonderful. I look forward to your responce(s)!

Thanks,

Knox.

Fri Feb 10, 2012 9:33 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Issues with Autonomous Code
The lag you notice is because you have wait statements in your while loop. The boolean statement in the while loop isn't being tested while you're waiting. By the way, I don't know if this is a typo when posting your code, but you have used "wait10Msec(2000)" when moving forward. This will wait for 20 seconds, which sounds like an awfully long time to move 3 feet. I don't quite understand what you mean by "have it always checking for the canister and keep going 3 feet forward and then turn 195 degrees". What do you want to happen when the button is pressed? Does the robot stop? Maybe something like this?
 Code:task main(){  ClearTimer(T1);  while((SensorValue[touch] == 0) && (time1[T1] < 2000)) {        // While there is nothing in the claw, keep on moving        motor[Left] = 80;        motor[Right] = 80;  }  ClearTimer(T1);  while((SensorValue[touch] == 0) && (time1[T1] < 1950)){    motor[Left] = 20;                       // Turn    motor[Right] = 65;  }  motor[Left] = 0;  motor[Right] = 0;}

You are running all of this with timing, a strategy called "dead reckoning". This is usually very imprecise, and does not seem to fit your what you want to do. For example, you want to "turn 195 degrees". This level of precision is usually not possible without using sensors. As for turning and travelling directly across the field from the light source, I don't think that the strategy that you have described would work. Using the lego ultrasonic sensor to determine angles in that way doesn't seem feasible to me. At most, you could estimate the direction, and then correct yourself when you get near the other corner. Are you allowed to go down the sides of the field instead of cutting through the middle? That seems much more doable.

_________________
sudo rm -rf /

Last edited by magicode on Sat Feb 11, 2012 12:44 am, edited 3 times in total.

Fri Feb 10, 2012 11:27 pm
Rookie

Joined: Fri Feb 10, 2012 9:07 pm
Posts: 2
Re: Issues with Autonomous Code
The wait10Msec was a mistake, but im trying to have it run a continuous loop looking for the objects I need to sort. So it has to move 3 or so feet forward and then turn to make that next 3 or so feet at a slight angle as to not make a oval like shape, but a flower type pattern covering a large area. I have the actual movement down, i just needed the touch sensor to always stop the robot and close my claw when it was pressed. I'll try the code you wrote and get back to you about it.

Also, for the navigation, ive wrote some code utilizing the walls and the fact that if i turn towards the light and figure out which walls my robot is by, i can get a rough estimate of where I am and then use the walls and left hand turns to get me to the nuclear corner.

Thanks for the response!

-Knox

Fri Feb 10, 2012 11:47 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning