Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Robot Needs To Follow A Parkour, Canít Seem To Make It Work

  1. #1
    Junior Member TimBC's Avatar
    Join Date
    Jun 2017
    Location
    Netherlands
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Robot Needs To Follow A Parkour, Canít Seem To Make It Work

    Hello, we have a subject thatís called NLT (Nature, life and technology), every time we do a different project and this time we need to code a robot in Java (or as the book calls it: a simplified version of Java). We are working in Eclipse.
    Our robot needs to follow a black line and avoid an object at the end of the line.
    Here are the requirements:
    1. The Robot drives for 1 second, stops 1 sec and follows the line after that.
    2. The Robot needs to finish the parkour under 45 seconds.
    3. If we have the fastest time we get bonus points.
    4. Every tight corner is made.
    5. Every normal corner is made.
    6. The object is in a controlled manner avoided.
    7. The robot stops on the yellow finish.
    8. A part must be driven with one sensor (the color sensor)
    9. A Part must be driven with two sensors (also the colors sensors)
    10. There must be a subroutine in the code thatís utilized.
    11. The robot must put what itís doing on its LCD display and in the server messages.
    12. There must be a íself-madeí piece of code.
    13. The program is indexed and made easy to look at.
    The robot has a distance sensor and a color sensor that I know off.
    As we are not very good at coding and have tried a lot but I donít think we have the most efficient code so we would really like some help!
    We would like to make it so it follows the line a lot faster. Also, we do not know how to switch to a different state from the line follower.
    One of the bigger problems is that in a subroutine it stops using the subroutine after like the third one and just keeps doing the third given subroutine.
    We thought of using a timer that would count and when itís done counting it would avoid the object, donít know if thatís the best way though.
    We only need to drive the robot in the simulator so there wouldnít be any inaccurate sensors or something similar.
    We would really like some help, even if itís just a small thing, we really appreciate it!
    P.S: If you need more, like the whole workspace we have been working in or when something is unclear, donít be scared to ask! (P.P.S Sorry if my English wasnít clear, we are Dutch)
    Have a good one,
    Tim and his group.

    package javaBot.Nano.Rescue;
     
    import com.muvium.apt.PeriodicTimer;
     
    public class DriveBehavior05 extends Behavior {
    	private BaseController joBot;
    	private int state = 1;
    	private int	count = 0;
    	int fl = 0;
    	int fr = 0;
    	int ds = 0;;
    //Subroutine Defined
    	private void jobotDrive (int curState, int newState, int l, int r, int t) {
    		if (state == curState) {
    			joBot.drive(l, r);
    			if (count++ >=  t) {
    				state = newState;
    				joBot.printLCD("State="+ state);
    				count = 0;
    			}	
    		}
    	}
    	public DriveBehavior05(BaseController initJoBot,
    			PeriodicTimer initServiceTick, int servicePeriod) {
    		super(initJoBot, initServiceTick, servicePeriod);
    		joBot = initJoBot;
    	}
     
    	public void doBehavior() 
    	// Robot Drives one second, stops one second and continues
    	{			
    		jobotDrive(1, 2, 100, 100, 10);
    		jobotDrive(2, 3, 0, 0, 10);
     
    		if (state == 3) {
    			System.out.println("Line Follower");
    			joBot.setStatusLeds(false, false, false);
    			joBot.drive(100, 100);	// Drives Straight
    			joBot.setFieldLeds(true);	// Turns on Field Leds
    			state = 4;
    		}
    //Color Sensor Follower
    		if (state == 4) {	
    			ds = joBot.getSensorValue(BaseController.SENSOR_DS);
    			fl = joBot.getSensorValue(BaseController.SENSOR_FL); // Left sensor
    			fr = joBot.getSensorValue(BaseController.SENSOR_FR); // Right sensor
    			if (fl < 350) {
    				joBot.drive(10, 60);	// Go left
    				joBot.setLed(BaseController.LED_GREEN, true);
    			}
    			if (fr <  350) {
    				joBot.drive(60, 10);	// Go right
    				joBot.setLed(BaseController.LED_GREEN, false);
    			}
    		}
    		count ++;
    		if (count >= 400){
    			state = 5;
    		}
    		//non working soubroutine
    		{			
    			jobotDrive(5, 6, 100, 0, 10);
    			jobotDrive(6, 7, 100, 100, 20);
    			jobotDrive(6, 7, 0, 100, 10);
    			jobotDrive(7, 8, 100, 100, 20);
    		}
    		if (state == 5){
    			joBot.drive (0,0);
    		}
    	}
    }
    Attached Images Attached Images

  2. #2
    Member
    Join Date
    May 2017
    Location
    Eastern Florida
    Posts
    68
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Robot Needs To Follow A Parkour, Canít Seem To Make It Work


  3. #3
    Junior Member TimBC's Avatar
    Join Date
    Jun 2017
    Location
    Netherlands
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Needs To Follow A Parkour, Canít Seem To Make It Work

    Got to have a as big audience as possible, is that bad? Sorry if I offended anyone.

  4. #4
    Member
    Join Date
    May 2017
    Location
    Eastern Florida
    Posts
    68
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Robot Needs To Follow A Parkour, Canít Seem To Make It Work

    It's ok to cross post as long as you provide a link to the other sites so anyone trying to help can see the current status of the problem and not waste time repeating what has already been said.

Similar Threads

  1. can someone help me make this work!
    By pointblank12 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 5th, 2014, 08:33 PM
  2. Replies: 3
    Last Post: January 26th, 2014, 10:51 PM
  3. how to work wsimport for this WSDL i get errors and i cant make it work
    By pato.llaguno in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 24th, 2014, 04:27 PM
  4. Replies: 1
    Last Post: July 9th, 2011, 07:17 AM
  5. Make my code follow MVC
    By alpvii in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 29th, 2010, 06:48 AM

Tags for this Thread