I could not find a way to rotate in place under encoder control using Python. I tried left_rot() and right_rot(), but these do not seem to be under encoder control. I can use the encoder and move only one of the wheels to turn the robot, but this requires more room to maneuver. I want to turn in place using encoder control. Is there a way to do this? Thanks!!!
The encoder targeting function works for both the wheels and works irrespective of the direction and waits for encoder count on both the motors to exceed the target, value and then stop the motors. Di you try using the encoder target function while rotating the GoPiGo in it’s place.
I’m not sure what function to try for the in place rotation in Python. For moving forward, I have the following function:
# Go forward by a fixed amount def go_forward(forward_distance): encoder_steps_required = int(forward_distance / DISTANCE_PER_ENCODER_STEP) gopigo.set_speed(DEFAULT_ROBOT_SPEED) gopigo.enc_tgt(1, 1, encoder_steps_required) gopigo.fwd()
I have a similar function for going back. For turning in place, I would need to turn the wheels in opposite directions. I don’t know what already available functions I can use to do this. Let’s say that I decide that I need 5 encoder steps in each wheel, but in opposite directions. How do I make the wheels turn in opposite directions? The fwd() and bwd() functions work on both wheels together in the same direction.
There is a function left_rot() to rotate the GoPiGo in place left and another right_rot() to rotate it right. Can you try them out and see if they help.
Thanks for the quick response. I got left_rot() and right_rot() to work under encoder control. I have to wait till the weekends before I can get back to programming the GoPiGo.