Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Hold after running forever leads to sudden motion #956

Closed
laurensvalk opened this issue Feb 18, 2023 · 5 comments
Closed

[Bug] Hold after running forever leads to sudden motion #956

laurensvalk opened this issue Feb 18, 2023 · 5 comments
Labels
bug Something isn't working topic: motors Issues involving motors topic: remote control Issues related to remotly controlling hubs

Comments

@laurensvalk
Copy link
Member

laurensvalk commented Feb 18, 2023

Describe the bug

The hold triggers it to suddenly move fast instead of hold, because there is an unexpected jump in the target position.

image

To reproduce

try:
    from pybricks.pupdevices import Motor
except ImportError:
    from pybricks.ev3devices import Motor
from pybricks.tools import wait
from pybricks.parameters import Port
from pybricks import version

print(version)

# Initialize the motor.
motor = Motor(Port.A)

# Allocate the data logs.
DURATION = 7000
motor.log.start(DURATION)
motor.control.log.start(DURATION)

motor.run(1000)
wait(2000)
motor.run(50)
wait(2000)
motor.hold()
wait(2000)


# Transfer data logs.
print("Transferring data...")
motor.log.save("servo.txt")
motor.control.log.save("control.txt")
print("Done")
@laurensvalk laurensvalk added bug Something isn't working topic: motors Issues involving motors topic: remote control Issues related to remotly controlling hubs labels Feb 18, 2023
@laurensvalk
Copy link
Member Author

This looks related to the motor not being able to hit the commanded speed in the first move.

@laurensvalk
Copy link
Member Author

Indeed, the same happens on SPIKE if the speed limit cap is raised. This means it can also happen with the normal cap if it can't reach the target speed under a load.

try:
    from pybricks.pupdevices import Motor
except ImportError:
    from pybricks.ev3devices import Motor
from pybricks.tools import wait
from pybricks.parameters import Port
from pybricks import version

print(version)

# Initialize the motor.
motor = Motor(Port.A)

# Allocate the data logs.
DURATION = 7000
motor.control.limits(speed=2000)
motor.log.start(DURATION)
motor.control.log.start(DURATION)

motor.run(2000)
wait(2000)
motor.run(100)
wait(2000)
motor.hold()
wait(2000)


# Transfer data logs.
print("Transferring data...")
motor.log.save("servo.txt")
motor.control.log.save("control.txt")
print("Done")

image

@laurensvalk
Copy link
Member Author

laurensvalk commented Feb 18, 2023

This means it can also happen with the normal cap if it can't reach the target speed under a load.

This is even worse for the following, slowing down the motor with your hand while it tries to move fast.

try:
    from pybricks.pupdevices import Motor
except ImportError:
    from pybricks.ev3devices import Motor
from pybricks.tools import wait
from pybricks.parameters import Port
from pybricks import version

print(version)

# Initialize the motor.
motor = Motor(Port.A)

# Allocate the data logs.
DURATION = 7000
motor.log.start(DURATION)
motor.control.log.start(DURATION)

motor.run_time(1000, 2000)
motor.run_time(100, 2000)
motor.run_angle(500, 720)

# Transfer data logs.
print("Transferring data...")
motor.log.save("servo.txt")
motor.control.log.save("control.txt")
print("Done")

image

EDIT: This is just an issue with the plot switching to log scale:
control

@laurensvalk
Copy link
Member Author

laurensvalk commented Feb 18, 2023

There is also still something wrong with the condition that releases the integrator pause. The position error gets inflated rather than slowed down. See new issue in #958.

Also notice the long time between commands. Is this delay EV3 specific?

image

try:
    from pybricks.pupdevices import Motor
except ImportError:
    from pybricks.ev3devices import Motor
from pybricks.tools import wait
from pybricks.parameters import Port
from pybricks import version

print(version)

# Initialize the motor.
motor = Motor(Port.A)   # EV3 Large

# Allocate the data logs.
DURATION = 7000
motor.control.limits(speed=2000)
motor.log.start(DURATION)
motor.control.log.start(DURATION)

motor.run_time(1800, 3000)
motor.run_time(100, 1000)
motor.run_angle(500, 720)


# Transfer data logs.
print("Transferring data...")
motor.log.save("servo.txt")
motor.control.log.save("control.txt")
print("Done")

@laurensvalk
Copy link
Member Author

It seems like the new position trajectory does not compensate for the angle spent "stalling" on the time trajectory, so it catches up to compensate.

We need to compensate for this when transitioning from a speed based to an angle based trajectory, just as we have a transition case for the other way around already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic: motors Issues involving motors topic: remote control Issues related to remotly controlling hubs
Projects
None yet
Development

No branches or pull requests

1 participant