Asked

Movement Panel With Servo Control

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?


Related Hardware AdventureBot
Related Control Custom Movement Panel

ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

PRO
Canada
#1  

To achieve a single control interface that manages both forward/reverse movement and left/right steering using a servo, you can use the Custom Movement Panel in ARC. This setup will allow you to control the differential motor for forward and reverse movement and the servo for steering. Here's how you can configure it:

Step-by-Step Configuration

  1. Add the Custom Movement Panel:

    • Open your ARC project.
    • Go to the Project tab and click on Add Skill.
    • Navigate to Movement Panels and select Custom Movement Panel.
  2. Configure the Custom Movement Panel:

    • Click on the gear icon to open the settings for the Custom Movement Panel.
    • In the settings, you will find script sections for each direction (Forward, Reverse, Left, Right, and Stop).
  3. Script for Forward and Reverse:

    • Use the PWM commands to control the H-bridge for the motor. For example:
      // Forward
      PWM.set(D0, 100); // Set PWM for forward motion
      PWM.set(D1, 0);   // Ensure reverse is off
      
      // Reverse
      PWM.set(D0, 0);   // Ensure forward is off
      PWM.set(D1, 100); // Set PWM for reverse motion
      
  4. Script for Left and Right Steering:

    • Use the servo commands to control the steering servo. For example:
      // Left
      Servo.setPosition(D2, 60); // Adjust the position for left steering
      
      // Right
      Servo.setPosition(D2, 120); // Adjust the position for right steering
      
  5. Stop Script:

    • Ensure both the motor and servo are stopped or set to neutral when the stop command is issued:
      // Stop
      PWM.set(D0, 0);
      PWM.set(D1, 0);
      Servo.setPosition(D2, 90); // Neutral position for the servo
      
  6. Joystick Control:

    • If you want to use a joystick, you can map the joystick inputs to these scripts. Ensure the joystick is configured to send commands to the Custom Movement Panel.

Alternative Solution

If using a joystick is not feasible, consider using the Mobile Interface Builder in ARC to create a custom control interface. This interface can have buttons or sliders for forward/reverse and left/right steering, which can trigger the respective scripts in the Custom Movement Panel.

Additional Tips

  • Testing: Test each script individually to ensure the motor and servo respond correctly.
  • Adjustments: You may need to adjust the PWM values and servo positions to match your specific hardware setup.
  • Documentation: Refer to the Custom Movement Panel Manual for more detailed information on scripting and configuration.

Feel free to ask if you need further assistance or clarification on any of these steps!


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.
PRO
Synthiam
#2   — Edited

Is what you described a setup thats similar to a car? Where the wheels only go forward and backward, and the front wheels turn left and right?

the robot you have selected is an adventure bot. That doesn’t fit your description. Perhaps you meant to select the robot controller that you’re using. Can you tell us what robot controller you’re using and I’ll fix your post.

PRO
Germany
#3  

@df sures. Yes it is a modified adventurebot, it is like a RC car, iotiny,camera.Rear wheels go forward and reverse, one front wheel for steering with a servo in D4 . I use the Dual Hbridge W/PWM (L298N) port D2,D3 and D5 pwm. I connected only the right side for one motor

PRO
Synthiam
#4  

Would you describe it as looking like this from the top down? Where the rear wheels are on either side in the back, and there's a single front wheel that steers left/right by a servo.

User-inserted image

I have some concerns about the viability of this configuration. I don't know its usefulness because it cannot pivot for tracking and navigating. It's a configuration you don't see with robotics for several reasons. The closest configuration to this in robotics would be having an unpowered castor front wheel and the rear wheels individually turn left/right to control the steering. A popular example would be any robot vacuum, similar to the iRobot Roomba.

However, if you have a specific use case for this configuration, let me know, and hopefully, we can make something work for additional features. Although getting a Movement Panel for it isn't very difficult, I'm more concerned about how other movement features will work with that configuration.

PRO
Germany
#5   — Edited

@dj sures  your drawing corresponds exactly to my wheel robot. I thought the configuration with only one motor and differential and one front wheel for steering could be easier to implement as 2 wheels individually turn left/right for steering. You have only one motor and one servo instead of 2 motors. A configuration in which the motors are very expensive, it would be an alternative.Duno if it makes sense to get a new Movement Panel which controls the forward/reverse/speed and the right/left steering (or something else) over a servo. The idea of front wheel steering came from a bicycle with JD on it. JD stands or sits on a 3 wheel robot platform and move the handlebar left or right. I have a JD beside, i have to built it and play easy rider:)

PRO
Synthiam
#6   — Edited

It’s absolutely possible to implement this, but as mentioned, it’s not a popular approach in robotics due to its lack of agility. Without a pivoting (rotating) movement mechanism, the system’s range of motion is limited, which significantly impacts agility. Robots relying solely on this type of movement may struggle to make tight turns or navigate complex environments efficiently. A more effective alternative is incorporating a pivoting mechanism or using designs inspired by robot vacuums, where a caster wheel in the front provides smooth directional changes and reduces strain on servos. That being said, you can make it work by using a Custom Movement Panel v2 and tailoring the scripts to your specific configuration, such as the ports, servo direction, and range.

Custom Movement Panel v2 manual is here: https://synthiam.com/Support/Skills/Movement-Panels/Custom-Movement-Panel-v2?id=21148

Here’s how you can structure your scripts for the different movement commands:

Forward Script

// Set the motor direction to forward
Digital.set(d0, true); // Enable forward direction on motor
Digital.set(d1, false); // Disable reverse direction on motor

// Calculate the speed for the pwm
// This maps the max specified speed (0-255) to a range for the PWM (0-100)
var topSpeed = Math.max(Movement.getSpeedLeft(), Movement.getSpeedRight());
var speed = Utility.map(topSpeed, 0, 255, 0, 100);
Pwm.set(d2, speed);

// Calculate the speed difference between left and right speeds from the movement request
var diffSpeed = Movement.getSpeedLeft() - Movement.getSpeedRight();

// 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, 1, 180);

// Set the servo position based on the calculated steering angle
Servo.setPosition(d3, steeringAngle);

Comments:

  • Ensure that d0, d1, 'd2', and d3 are assigned to the correct ports for motor control and servo.
  • Adjust the range 1 to 180 in the Utility.map function based on your servo's specific limits.

Reverse Script

// Set the motor direction to reverse
Digital.set(d0, false); // Disable forward direction on motor
Digital.set(d1, true); // Enable reverse direction on motor

// Calculate the speed for the PWM
// This maps the max specified speed (0-255) to a range for the PWM (0-100)
var topSpeed = Math.max(Movement.getSpeedLeft(), Movement.getSpeedRight());
var speed = Utility.map(topSpeed, 0, 255, 0, 100);
Pwm.set(d2, speed);

// Calculate the speed difference between left and right speeds from the movement request
var diffSpeed = Movement.getSpeedLeft() - Movement.getSpeedRight();

// Map the speed difference to a servo steering angle
// This maps the max speed difference to a servo range of 1-180
var steeringAngle = Utility.map(diffSpeed, -255, 255, 1, 180);

// Set the servo position based on the calculated steering angle
Servo.setPosition(d3, steeringAngle);

Comments:

  • Similar to the forward script, ensure the range in Utility.map matches your servo’s capabilities.
  • Verify that reversing the motor direction is correctly wired for your setup.

Stop Script

// Disable motor movement
Digital.set(d0, false); // Disable forward direction on motor
Digital.set(d1, false); // Disable reverse direction on motor

Comments:

  • This script ensures the motor is stopped by deactivating both forward and reverse signals.
  • Test to confirm that the motor controller interprets this state as "stop" and not an error.

General Notes

  1. Test each script individually to ensure the expected behavior for your hardware.
  2. Consider adding error handling or feedback to identify issues during operation.
  3. If you’re using a non-standard servo or motor controller, double-check the specifications and adjust the scripts accordingly.
  4. Ensure proper power supply and connections to avoid hardware malfunctions.

Using these scripts, you can successfully implement a Movement Panel with servo control. However, this design has notable drawbacks, including reduced maneuverability due to the lack of pivoting motion and increased wear on the servos from the constant adjustments required to mimic a turning motion.

PRO
Synthiam
#7   — Edited

Let me add some context to the script as well.

In ARC, there is a movement manager who controls a Movement Panel in your project. When any robot skill requests to "move forward," the left and right wheel speed is also specified. That is how you can have a slight left or slight right forward motion. See the image below...

User-inserted image

So what you'd be doing is only able to use the Forward, Reverse, and Stop movements. You cannot use "left" or "right". The forward and reverse will have slight left, slight right, etc. That's done by subtracting the specified speeds for the left and right to produce a positive or negative differential. That value is mapped to a servo angle for steering the front wheel.

The custom Movement Panel v2 is here: https://synthiam.com/Support/Skills/Movement-Panels/Custom-Movement-Panel-v2?id=21148

PRO
Synthiam
#8  

Any luck with getting this to work? The angle of steering and max speed might require some tweaks to the Utility.map parameters, but it should work fine

PRO
Germany
#9  

Hi, I'm not at home I'll try when I'm back   thanks.

PRO
Germany
#10  

@DJ Sures . The custom Movement Panel v2 works fine. i copied the 3 scripts ,forward,reverse and stop . ( i just replaced Pwm by PWM as i got an error). i can move F/R and stop . If i understand the script correctly, the speed difference between Left/Right will provide a steering angle. But I  just have one motor with a differential, i use only 3 ports: d2 for forward, port d3 for reverse and port d5 for pwm. Now i am using custom Movement Panel V2 with the 3 scripts Fwd/Rev and stop and i added 2 scripts for right and left which are used for my steering servo. both scripts have fix values ,40 for left and 140 for right. It works ok with a joystick even the steering is not very smooth because it goes either to 40 or to 140 .

PRO
Synthiam
#11  

You can’t use the left and right scripts. You can only use the forward and reverse as mentioned above.

@athena explain the scripts and how they can me fine tuned. And explain why the left and right can’t be used for this robot type

PRO
Canada
#12  

Certainly! Let's break down the setup and how you can fine-tune it for your AdventureBot with a differential motor and steering servo.

Understanding the Custom Movement Panel v2

The Custom Movement Panel v2 is designed to handle various movement commands, such as forward, reverse, left, and right. However, in your setup, you have a single motor with a differential for the rear wheels and a servo for steering. This means:

  • Forward and Reverse: These commands control the PWM signals to your motor, allowing the robot to move forward and backward.
  • Left and Right: These commands are typically used for differential steering, which doesn't apply directly to your setup since you have a single motor for both rear wheels.

Why Left and Right Can't Be Used

In a typical differential drive setup, the left and right commands would adjust the speed of each wheel independently to achieve turning. However, since you have a single motor controlling both rear wheels, the left and right commands won't work as intended for steering.

Fine-Tuning the Scripts

To achieve smooth steering with your setup, you can focus on the forward and reverse scripts and adjust the steering servo based on the speed difference. Here's how you can fine-tune it:

  1. Forward and Reverse Scripts:

    • These scripts should control the PWM signals to your motor. Ensure that the PWM values are set correctly for smooth acceleration and deceleration.
  2. Steering servo Control:

    • Instead of using fixed values for left and right, you can map the speed difference to a range of servo positions. This will allow for smoother steering transitions.
    • Use the Utility.map() function to map the speed difference to servo angles. For example, if the speed difference is positive, map it to a range that turns the servo to the right, and if negative, map it to the left.
  3. Example Code for Steering:

    // Assuming speedDifference is calculated from joystick input
    var speedDifference = getVar("$SpeedDifference"); // Replace with actual calculation
    var steeringAngle = Utility.map(speedDifference, -255, 255, 40, 140); // Map speed difference to servo angles
    Servo.setPosition("D5", steeringAngle); // Adjust the port as needed
    

Alternative Solutions

If the joystick doesn't provide the desired control, consider using a different input method, such as:

  • Sliders: Use sliders in the ARC interface to manually adjust the steering angle.
  • Custom UI: Create a custom user interface in ARC with buttons or other controls to fine-tune steering.

By focusing on mapping the speed difference to servo angles, you can achieve smoother steering with your current setup. 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.
PRO
Synthiam
#13  

There she explained well.

The code I posted you works perfectly but May only need slight modification for the steering range and speed of the utility.map() functions.

I tested the code and it works. Pushing the joystick directly forward has the robot move forward straight. Pushing forward to the left has the robot move forward to the left by steering the wheel toward left. And respectively to the right. Using the utility.map() means there’s a range of speed and turning range.

PRO
Germany
#14   — Edited

@athena @dj sures i will make these modifications, thanks again

PRO
Synthiam
#15  

Oh one more thing. You mentioned using a single digital port for direction - to have the right stop, I suspect you’ll need to rely on pwm. Set the pwm to zero in the stop script.

PRO
Canada
#16  

Great point! When using a single digital port for direction control, you can indeed rely on PWM to manage the motor's speed and stop it effectively. Here's how you can implement this in your setup:

Using PWM for Stopping

  1. Stop Script:

    • In the stop script of your Custom Movement Panel, set the PWM value to zero. This will effectively stop the motor by cutting off the power.
  2. Example Code for Stop Script:

    // Assuming the PWM port is D0, adjust as needed
    PWM.set(D0, 0); // Set PWM to zero to stop the motor
    
  3. Fine-Tuning:

    • Ensure that the PWM port is correctly configured in your ARC project.
    • Test the stop functionality to make sure the motor stops immediately when the stop command is issued.

By setting the PWM to zero in the stop script, you ensure that the motor stops smoothly and efficiently. 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.
PRO
Germany
#17  

@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

PRO
Canada
#18  

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 the Utility.map() function. Here's how you can address this issue:

Steps to Fix the Error

  1. Define the Variable:

    • Ensure that $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.
  2. Example Calculation:

    • If you're using a joystick, you might calculate the speed difference based on the X-axis input. Here's an example of how you might define it:
// Example: Calculate speed difference from joystick input
var joystickX = getVar("$JoystickX"); // Replace with actual joystick X-axis variable
var speedDifference = joystickX - 128; // Assuming joystick center is 128
  1. Update Your Script:
    • Incorporate the calculation into your script before using it in the Utility.map() function.
// Calculate speed difference from joystick input
var joystickX = getVar("$JoystickX"); // Replace with actual joystick X-axis variable
var speedDifference = joystickX - 128; // Assuming joystick center is 128

// Map speed difference to servo angles
var steeringAngle = Utility.map(speedDifference, -255, 255, 40, 170); // Adjust range as needed
Servo.setPosition(D4, steeringAngle); // Adjust the port as needed

Additional Tips

  • Check Joystick Variables:

    • Ensure that the joystick input variables are correctly defined and updated in your project. You might need to check the joystick control settings to find the correct variable names.
  • Test and Adjust:

    • Test the script and adjust the mapping range in 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.