plz Help; How to make a robot follow Distance? (NXC)
plz Help; How to make a robot follow Distance? (NXC)
Dear memebers,
I'm a college student who's new in programming with NXC
but I came across a problem which is ,I don't know how to make an NXT robot walk for a specific distance ?
for instance: I want to make the robot move forward 7 meters ??
what's the code?
I'm a college student who's new in programming with NXC
but I came across a problem which is ,I don't know how to make an NXT robot walk for a specific distance ?
for instance: I want to make the robot move forward 7 meters ??
what's the code?
Re: plz Help; How to make a robot follow Distance? (NXC)
if you mean "go ahead" by wheels :
you may calculate how many rotations you need for each wheel to go 7 meters.
for instance, if the wheel circumference is 20 cm, you need 35 rotations with 360° each = 35*360 = 12600 encoder counts
so start your engines
monitor the rotation counts
and if rotation counts >= 12600 then stop your engines.
If you mean "walk" for a humanoid robot, you will have to count the step size analogously instead of wheel rotations.
Of course more advanced navigation algorithms are possible, based on odometry, compass, and gyro sensor - such a project is already discribed in the projects subforum.
HTH!
you may calculate how many rotations you need for each wheel to go 7 meters.
for instance, if the wheel circumference is 20 cm, you need 35 rotations with 360° each = 35*360 = 12600 encoder counts
so start your engines
monitor the rotation counts
and if rotation counts >= 12600 then stop your engines.
If you mean "walk" for a humanoid robot, you will have to count the step size analogously instead of wheel rotations.
Of course more advanced navigation algorithms are possible, based on odometry, compass, and gyro sensor - such a project is already discribed in the projects subforum.
HTH!
Re: plz Help; How to make a robot follow Distance? (NXC)
it's exactly as you saiddoc-helmut wrote:if you mean "go ahead" by wheels :
you may calculate how many rotations you need for each wheel to go 7 meters.
for instance, if the wheel circumference is 20 cm, you need 35 rotations with 360° each = 35*360 = 12600 encoder counts
so start your engines
monitor the rotation counts
and if rotation counts >= 12600 then stop your engines.
but I'm using NXC and the code for moving forward is like this one >>
Code: Select all
OnFwd(OUT_C, 75);
Wait(4000);
but I need is to make it move by distance not speed ?
I thought maybe to use the equation (D=S x T T=D/S S= D/T /=divide x=multiply. D=distance. S=speed. T=time) by calculating the amount of time the robot takes to do 1 meter with a speed of 75 ...
but I need a better solution coz Im not sure if that will work
thank you so much ,,,and sorry for my poor english ^_^"
Re: plz Help; How to make a robot follow Distance? (NXC)
From the NXC Programmer's Guide byJohn Hansen
RotateMotor(outputs, pwr, angle) Function
Run the specified outputs forward for the specified number of degrees.
Outputs can be a constant or a variable containing the desired output ports.
Predefined output port constants are defined in Table 20.
RotateMotor(OUT_A, 75, 45); // forward 45 degrees
RotateMotor(OUT_A, -75, 45); // reverse 45 degrees
RotateMotorEx(outputs, pwr, angle, turnpct, sync, stop) Function
Run the specified outputs forward for the specified number of degrees.
Outputs can be a constant or a variable containing the desired output ports.
Predefined output port constants are defined in Table 20.
If a non-zero turn percent is specified then sync must be set to true or no turning will occur.
Specify whether the motor(s) should brake at the end of the rotation using the stop parameter.
RotateMotorEx(OUT_AB, 75, 360, 50, true, true);
RotateMotor(outputs, pwr, angle) Function
Run the specified outputs forward for the specified number of degrees.
Outputs can be a constant or a variable containing the desired output ports.
Predefined output port constants are defined in Table 20.
RotateMotor(OUT_A, 75, 45); // forward 45 degrees
RotateMotor(OUT_A, -75, 45); // reverse 45 degrees
RotateMotorEx(outputs, pwr, angle, turnpct, sync, stop) Function
Run the specified outputs forward for the specified number of degrees.
Outputs can be a constant or a variable containing the desired output ports.
Predefined output port constants are defined in Table 20.
If a non-zero turn percent is specified then sync must be set to true or no turning will occur.
Specify whether the motor(s) should brake at the end of the rotation using the stop parameter.
RotateMotorEx(OUT_AB, 75, 360, 50, true, true);
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: plz Help; How to make a robot follow Distance? (NXC)
You can find all commands in the documentation, the most up-to-date version is found here: http://bricxcc.sourceforge.net/nbc/nxcdoc/nxcapi/. The motor commands are found in "Modules->NXT Firmware Modules->Output module". Be aware that some commands require the latest test version of BCC and the enhanced firmware in order to work. You can get the test releases here: http://bricxcc.sourceforge.net/test_releases/
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: plz Help; How to make a robot follow Distance? (NXC)
you also may use OnFwd, but as I mentioned, you also have to monitor the encoder:
Maybe you wish to have a look at the NXC tutorial by Daniele Benedettelli? http://bricxcc.sourceforge.net/nbc/nxcd ... torial.pdf
Code: Select all
OnFwd(OUT_C, 75); // start motor C by power 75%
while (MotorRotationCount(OUT_C)<12600); // wait until target count reached
Off(OUT_C); // then switch off motor
Re: plz Help; How to make a robot follow Distance? (NXC)
THANKS A LOT GUYS FOR THE HELP
but..
I just have one more questions if you may!
I guess I'll be following the counting methoddoc-helmut wrote:you also may use OnFwd, but as I mentioned, you also have to monitor the encoder:Code: Select all
OnFwd(OUT_C, 75); // start motor C by power 75% while (MotorRotationCount(OUT_C)<12600); // wait until target count reached Off(OUT_C); // then switch off motor
but..
I just have one more questions if you may!
I don't get how you interpreted the 35 rotations? can you explain it plz ?20 cm, you need 35 rotations with 360° each = 35*360 = 12600 encoder counts
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: plz Help; How to make a robot follow Distance? (NXC)
If one full rotation (360°) moves the robot 20 cm forward, the amount of rotations to go the full distance would be 700 cm / 20 cm = 35. So in degrees it would be 35 * 360° = 12600°.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: plz Help; How to make a robot follow Distance? (NXC)
aha! now I get it !spillerrec wrote:If one full rotation (360°) moves the robot 20 cm forward, the amount of rotations to go the full distance would be 700 cm / 20 cm = 35. So in degrees it would be 35 * 360° = 12600°.
thanks a million ;D
Who is online
Users browsing this forum: Semrush [Bot] and 8 guests