View unanswered posts | View active topics It is currently Wed Aug 05, 2020 4:46 am

Reply to topic  [ 2 posts ] 
Author Message

Joined: Wed Oct 01, 2014 12:35 pm
Posts: 3
Post getDistanceValue
This command seems to have a sonar that looks rearward from the standard Clawbot. I am trying to use it in the VEX Highrise Virtual World, which starts with the robot at one end of field and 3 cubes at the other end lined up along the robot's nominal direction of travel. If I move the robot forward the distance returned by the getDistanceValue keeps increasing as the robot approaches the first block in the line. If I turn the robot around by 180 degrees and move it backwards toward the blocks the distance decreases. The following code illustrates the problem:

#pragma config(StandardModel, "VEX IQ Clawbot")

task main()
// turnLeft(540,degrees,50);
float x=getDistanceValue(port7);

This code calculates an increasing value for x as the robot moves toward the blocks, eventually colliding with the blocks and pushing them off the field. If I uncomment the turnLeft command, and change the forward to a backward, the robot stops in front of the first block. What is wrong?

Mon Oct 06, 2014 3:33 am
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: getDistanceValue

The forward command may be the cause of your problems; when you use the forward command, the robot will move forward for the specified units (seconds), for the specified quantity (1), at the specified speed (20). During the forward movement, the robot will forward(1,seconds,20);NOT be checking any other sensors or loop conditions. Once the forward movement has completed, the robot will stop moving for 500 milliseconds and then move on to the next line in the program.

Instead of using the forward command, you can use the setMotor command to individually assign motor values to the IQ's motors:

setMotor(rightMotor, 20);
setMotor(leftMotor, 20);


Once the robot has reached its target value range of either less than 100 or greater than 2000, you should stop the robot manually (you can use a stop() command to do so) to ensure that it comes to a complete stop when you want it to.

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Tue Oct 14, 2014 6:09 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.