
jp15sil24

I have modified my 3-wheel robot by replacing the two 360-degree servos with a motor equipped with a differential. This motor is controlled by a dual H-bridge using PWM signals. While I'm not entirely sure if this is the optimal setup, I'm still learning and experimenting with various possibilities. Currently, the single motor controls both rear wheels, allowing for synchronized forward and reverse movement, which is functioning well.
For steering, I have installed a servo at the front to control the wheel's left-right movement. However, I'm encountering an issue where the joystick correctly manages the forward and reverse motion but fails to control the steering. I would like to have a single control interface or "tool" that can manage both forward/reverse and left/right steering using the servo. If achieving this with a joystick is not feasible, could you suggest an alternative solution?
@athena i got an error with the following script:
// Assuming speedDifference is calculated from joystick input var speedDifference = getVar("$SpeedDifference"); // Replace with actual calculation var steeringAngle = Utility.map(speedDifference, -255, 255, 40, 170); // Map speed difference to servo angles Servo.setPosition("D4", steeringAngle); // Adjust the port as needed
Start Execution Error Line 4 Col 0 - Variable not defined: $SpeedDifference Done (00:00:00.0077419) I thought a syntax error with speedDifference or SpeedDifference but it is the same
The error message indicates that the variable
$SpeedDifference
is not defined in your script. This variable needs to be calculated or set before you use it in theUtility.map()
function. Here's how you can address this issue:Steps to Fix the Error
Define the Variable:
$SpeedDifference
is calculated based on your joystick input. This variable should represent the difference in speed between the left and right directions of the joystick.Example Calculation:
Utility.map()
function.Additional Tips
Check Joystick Variables:
Test and Adjust:
Utility.map()
to suit your robot's steering requirements.If you have any more questions or need further assistance, feel free to ask!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Please use the scripts that I posted because it works, and was tested. The code Athena is posting is confusing because it’s about trying to turn and stuff - and us getting confused. The main topic of conversation we should stick to has been addressed in my scripts.
adjust the map values as needed for steering range and movement speed.
ok i go back to your scripts.
They will work great if you modify the range values for the steering and speed. Also remove the additional digital port if youre only using one wire.
as for the stop, simply specify the pwm to have a value of 0.
let me know your experience. The left and right scripts won’t work as the robot can’t pivot on spot with that configuration.
"dj sures, good news, it works ok. I have to play with some values to improve the control and something mechanical stuck at the steering servo I have to fix
that's good to hear - how's it going now?
heres a short video: https://www.youtube.com/watch?v=CRieRdpSgAA the steering control with horizontal servo works fine. it goes from left to right without problem. Whats is funny is when i first move forward with the joystick the steering goes to full-left then i can control the steering but it springs sometimes shortly left-right !! i cannot go full-right with the steering , duno why. i have the same utility.map for right and left: // Map the speed difference to a servo steering angle // The Utility.map function converts the difference to a range suitable for servo positioning // This maps the max speed difference to a servo range of 1-180 var steeringAngle = Utility.map(diffSpeed, -255, 255, 55, 180);
// Set the servo position based on the calculated steering angle Servo.setPosition(d4, steeringAngle);
It seems to me when the speed is higher, the steering angle on the right is better.Running on the floor, what is the normal behaviort, it is better, it does not spring shortly from left-right. i still can not steer full right,left is ok. I should invest more time with some values in the script. I'd like to make a test with a ps2 joystick connected to the pc.