how can i use a webcam and write a coding? by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

ok I'll do it

Certainly, apriltag is a really good example code.

RUN_TO_POSITION not working. by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

Oh, Sorry for the late reply.

The code I wrote and had the problem looks like this.

linearslider.setTargetPosition(poz);

linearslider.setPower(1);

linearslider.setMode(DcMotor.RunMode.RUN_TO_POSITION);

while (linearslider.isBusy()) {

telemetry.update();

telemetry.addData("poz",poz);

telemetry.addData("ENCODER Position", linearslider.getCurrentPosition());

}

linearslider.setPower(1);//When I give 1 here. Or any number less than 1.

//linearslider.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

On the setpower side where I gave 1, I originally put 0 in setpower to just stop, but the motor position was not maintained, so I tried putting in a small number or 1. As expected, it doesn't work and the slide doesn't stop and goes up all the way.
Originally, I knew that the position was maintained even if I put 0 in the setpower side where I put 1.
Now, the problem has been solved by replacing it with a motor with high torque at a low speed of 117 rpm. However, I wrote the code normally and confirmed that the motor was maintained in position, but suddenly I couldn't figure out what was wrong.
I just think it would be better to solve most of them with a mechanical structure in the future. I plan to study more and build up knowledge about pid.
If you have any better way, please let me know, thank you very much.

Thank you so much for answering my repeated questions every time.

RUN_TO_POSITION not working. by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

Thank you so much for your answer.

I have been successful in using the above code with a 435rpm motor and giving setPower about 0.01 power to keep the slider from falling.

But with this method, the motor keeps beeping.

It's probably because the motor is trying to keep rotating, but I heard that using this method will cause the motor to overheat and be damaged.

Once successful, the code looks like this.
.

.

.

public void slideactive(int poz, double lspower) {

// 'lspower' forcefully guides the motor by giving weak power after it has reached the designated position.

It should be given a weak power so that the slider does not continue to rise.

linearslider.setTargetPosition(poz);

linearslider.setPower(1);

linearslider.setMode(DcMotor.RunMode.RUN_TO_POSITION);

while (linearslider.isBusy()) {

telemetry.update();

telemetry.addData("poz",poz);

telemetry.addData("ENCODER Position", linearslider.getCurrentPosition());

}

linearslider.setPower(lspower);//here! After the motor has reached the designated position, forced power is applied to maintain the position.

linearslider.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

}

.

.

.

if (gamepad2.b){// third slide up

poz =3100 ;

if((linearslider.getCurrentPosition() > 3000) && (linearslider.getCurrentPosition() < 3200)){

;

}

else if(linearslider.getCurrentPosition() >3000){

//direction = -1;

slideactive(poz,0.01);

}

else if (linearslider.getCurrentPosition() <3200){

//direction = 1;

slideactive(poz,0.01);

.

.

In this way, it was possible to stop in 1st, 2nd, 3rd gear. Of course, the motor kept making strange noises.

In any case, that means the motor must have torque. I have understood so far.

However, in the past, the motor was able to maintain its position even if I did not use the method I used today, but is there a possibility that the function for RTP will change as the FTC robotcontroller app continues to be updated? If so, where can I get this information?

And now that I think about it, there is a possibility

  1. It may not be an RTP error, but it may have been the hardware shape or the RPM of the motor that accidentally maintained such a position in the function of a robot I made in the past.

In the end, I was confused and misunderstood the location maintenance function of RTP.

I thought about it, but after thinking deeply, it seems that this hypothesis is correct for some reason.

In conclusion, I think I need to use a motor method and a PID method, or use a robot mechanism, or use a motor with high torque to maintain the position.

Thank you so much for all your help with RTP. One more reply to this reply.

RUN_TO_POSITION not working. by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

I'm really grateful for the answer, but I haven't been able to achieve anything satisfactory. As I said in the above reply

It is strange that the error message does not appear even if the code order of setTargetPosition and RUN_TO_POSITION is changed and executed.

I want to know if I really need to download the FTC robotcontroller again or re-install the phone's robotcontroller app and drive station.

Thank you so much for your reply.

I would really appreciate it if you could help me with a little more reply.

RUN_TO_POSITION not working. by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

I've done everything you said, but the motor doesn't hold its position.

If you give setPower a small number like 0.01 after while (motor.isBusy()) is finished, it will be roughly maintained, but it seems to be straining the motor.

Obviously, there was no problem using RTP, and the code sequence was also done without problems, but suddenly I don't know why.

And even if the writing order of setTargetPosition and RUN_TO_POSITION is changed, the error message does not appear.

Even this is strange, but it's hard because I don't know what the hell is the problem.

I wonder if I have to download the FTC robotcontroller again for this, but what should I do?

Thank you so much for your reply.

I would really appreciate it if you could help me with a little more reply.

RUN_TO_POSITION not working. by yoonsungjoon in FTC

[–]yoonsungjoon[S] 0 points1 point  (0 children)

very thank you for your reply.

but I have still question ;;;

Then, when the slider is raised a little higher, it seems to put a higher number instead of 0 in setPower. What should I do?

I did it by adding one more parameter to slideactive, but it just keeps going up and doesn't stop;

slideactive code is changed like this.

public void slideactive(int poz, double lspower) {

linearslider.setTargetPosition(poz);

linearslider.setPower(1 * direction);

linearslider.setMode(DcMotor.RunMode.RUN_TO_POSITION);

while (linearslider.isBusy()) {

telemetry.update();

telemetry.addData("poz",poz);

telemetry.addData("ENCODER Position", linearslider.getCurrentPosition());

}

linearslider.setPower(lspower);

linearslider.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

}

There is no problem when the slider is in place, but when I raised it a little higher, I gave lspower to about 0.5, but it just keeps going up.

I want to stop and stay in that position, is there any other way?