ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

PRO
Canada
#1  

To make your Roli Rover's camera chase a ball and continue searching for it when it goes out of view, you can use the Camera Click servo and Face Tracking skills in combination with some scripting in ARC. Here's a step-by-step guide to achieve this:

  1. Add and Configure Camera Click Servo:

    • Ensure you have the Camera Click servo skill added to your project.
    • Physically mount your camera to a servo-controlled pan-tilt mechanism.
    • Connect the servos to the appropriate ports on your EZB.
    • Configure the horizontal and vertical servos in the Camera Click servo settings.
  2. Add and Configure Face Tracking:

    • Ensure you have the Face Tracking skill added to your project.
    • Configure the Face Tracking skill to track the ball. You might need to adjust the settings to recognize the ball as a face or use color tracking if the ball has a distinct color.
  3. Create a Script to Move the Camera:

    • You will need to create a script that moves the camera to search for the ball when it goes out of view. This script will use the Camera Click servo to pan and tilt the camera.
  4. Integrate the Skills with Scripting:

    • Use the ControlCommand() function to integrate the Camera Click servo and Face Tracking skills. You can use JavaScript or Python for scripting in ARC.

Here is an example script in JavaScript to move the camera and search for the ball:

// Function to move the camera to search for the ball
function searchForBall() {
    // Define the search pattern
    var searchPattern = [
        {x: 90, y: 90}, // Center
        {x: 45, y: 90}, // Left
        {x: 135, y: 90}, // Right
        {x: 90, y: 45}, // Up
        {x: 90, y: 135} // Down
    ];

    // Loop through the search pattern
    for (var i = 0; i < searchPattern.length; i++) {
        // Move the camera to the next position in the search pattern
        ControlCommand("Camera Click Servo", "SetPosition", searchPattern[i].x, searchPattern[i].y);
        sleep(1000); // Wait for 1 second to allow the camera to move

        // Check if the ball is detected
        if (getVar("$FaceTrackingDetected") == true) {
            // Ball detected, break out of the search loop
            break;
        }
    }
}

// Main loop to continuously track the ball
while (true) {
    // Check if the ball is detected
    if (getVar("$FaceTrackingDetected") == false) {
        // Ball not detected, start searching for the ball
        searchForBall();
    } else {
        // Ball detected, move the robot towards the ball
        ControlCommand("Roli Rover", "MoveForward");
    }

    sleep(500); // Wait for 0.5 seconds before checking again
}

Steps to Implement the Script:

  1. Add the Script to Your Project:

    • Open your ARC project.
    • Go to the Project tab and click on Add Control.
    • Select Scripting and add a JavaScript control.
    • Copy and paste the above script into the JavaScript control.
  2. Configure the Camera Click Servo:

    • Ensure the Camera Click servo is properly configured with the correct servo ports and limits.
  3. Configure the Face Tracking:

    • Ensure the Face Tracking skill is set up to detect the ball. You might need to adjust the settings to recognize the ball as a face or use color tracking.
  4. Run the Script:

    • Start the script by clicking the Start button in the JavaScript control.

This script will continuously check if the ball is detected. If the ball is not detected, it will move the camera in a predefined search pattern to locate the ball. Once the ball is detected, it will move the robot towards the ball.

Feel free to adjust the search pattern and timings to better suit your specific setup and environment. If you have any further questions or need additional assistance, please let me know!


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

thanks Athena. where can I find the face tracking skill ?

#3  

I think @Athena's suggestion is somewhat correct. However, her instructions may not have been very clear about where a script like this could execute.

The idea is to run a script when the "tracking stops" to search for the object. This is found in the camera device configuration screen under the "scripts & variables" tab. You will find a script to execute when "tracking ends." See this screenshot.

User-inserted image

Next, you can have the camera servo move to find the ball. The script in the "tracking end" would only need to run for a finite number of seconds. For example, searching for the ball for 2 seconds would be fine, but you could adjust it to your preference.

The camera would need to move to each specified coordinate in an array and pause between movements to find the object.

The "tracking end" script will automatically be stopped by the camera device when the "tracking start" script begins, so you will not need to stop the script if an object is found. The tracking end script merely needs to move the camera around, looking for the object. Because the object will be left or right, moving the camera up or down is unnecessary.

PRO
Germany
#4   — Edited

hi, i copied the javascript but it can not find the variable $FaceTrackingDetected. Into the camera skill , i have the tracking option with tracking types. i choose " face " but the skill searches for a face, i can not fool it with an object or color(ball).I tried to replace the variable $FaceTrackingDetected with ObjectTrackingDetected but this variable does not exist. In the intructions provided by Athena, it requests to have the skill "Face Tracking skill "installed but i can not find this skill.  in the "tracking end", i copied the script and clic on Run, it brings the error "variable not defined :$FaceTrackingDetected. I check the camera click servo, i setup the port d9 ,d10, and setup exactly the same values min,max for each servo. I got another error message: controlcommand Errorfor Camera click servo sending SetPosition , controlcommandwith parameter SetPosition90,90 is not supported for this control ( camera click servo)

Maybe i just have to install the Face Tracking Skill but i dont know where it is. thx jp

PRO
Canada
#6  

It seems there has been some confusion regarding the Face Tracking skill and the variables used for tracking. Let's clarify and provide a step-by-step guide to achieve your goal of having the camera move to locate the ball when it goes out of view.

Step 1: Add the Camera Device Skill

  1. Open ARC: Launch the ARC software on your computer.
  2. Add Control: Click on the Project tab at the top of the ARC window, then click on the Add Control button.
  3. Search for Camera Device: In the Add Control window, type Camera Device in the search bar.
  4. Add the Skill: Click on the Camera Device skill from the search results to add it to your project.

Step 2: Configure the Camera Device for Object Tracking

  1. Open Camera Device Configuration: Click on the gear icon of the Camera Device skill to open its configuration.
  2. Set Tracking Type: In the Tracking tab, select Color or Object tracking, depending on what you want to track (e.g., the color of the ball).
  3. Set Tracking Options: Configure the tracking options to suit your needs (e.g., color range for the ball).

Step 3: Add the Camera Click servo Skill

  1. Add Control: Click on the Project tab, then click on the Add Control button.
  2. Search for Camera Click Servo: In the Add Control window, type Camera Click Servo in the search bar.
  3. Add the Skill: Click on the Camera Click Servo skill from the search results to add it to your project.
  4. Configure servo Ports: Set the servo ports for the camera's pan and tilt servos (e.g., D9 and D10).

Step 4: Add the Script for Tracking End

  1. Open Camera Device Configuration: Click on the gear icon of the Camera Device skill to open its configuration.
  2. Go to Scripts Tab: Navigate to the Scripts tab.
  3. Add Tracking End Script: In the Tracking End script section, add the following JavaScript code:
// Define the positions to search for the ball
var positions = [
    { pan: 45, tilt: 90 },
    { pan: 90, tilt: 90 },
    { pan: 135, tilt: 90 },
    { pan: 90, tilt: 45 },
    { pan: 90, tilt: 135 }
];

// Function to move the camera to each position
function searchForBall() {
    for (var i = 0; i < positions.length; i++) {
        // Move the camera to the specified position
        ControlCommand("Camera Click Servo", "SetPosition", positions[i].pan, positions[i].tilt);
        // Wait for a short duration to allow the camera to move
        sleep(500);
        // Check if the ball is detected
        if (getVar("$ObjectTrackingDetected")) {
            break;
        }
    }
}

// Start searching for the ball
searchForBall();

Step 5: Test the Setup

  1. Run the Project: Start your ARC project and ensure all skills are connected and configured correctly.
  2. Test Object Tracking: Move the ball in and out of the camera's view to see if the camera follows the ball and searches for it when it goes out of view.

Troubleshooting

  • Variable Not Defined: Ensure you are using the correct variable names. For object tracking, use $ObjectTrackingDetected.
  • ControlCommand Error: Ensure the Camera Click Servo skill is correctly configured and supports the SetPosition command.

If you still encounter issues, please provide specific error messages or behavior details, and I'll be happy to assist further.


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
#7  

@athena

Do not use the camera click skill or face tracking. All you need is the camera device robot skill. Add a script to the tracking end, and have the script search for a ball. It only needs to move the servo left and right horizontally. Also, use the servo set position script commands to move the servo.

PRO
Canada
#8   — Edited

Thank you for the clarification, DJ_Sures. Let's simplify the process by using only the Camera Device skill and a script to move the camera horizontally to search for the ball. Here's how you can achieve this:

Step 1: Add the Camera Device Skill

  1. Open ARC: Launch the ARC software on your computer.
  2. Add Control: Click on the Project tab at the top of the ARC window, then click on the Add Control button.
  3. Search for Camera Device: In the Add Control window, type Camera Device in the search bar.
  4. Add the Skill: Click on the Camera Device skill from the search results to add it to your project.

Step 2: Configure the Camera Device for Object Tracking

  1. Open Camera Device Configuration: Click on the gear icon of the Camera Device skill to open its configuration.
  2. Set Tracking Type: In the Tracking tab, select Color or Object tracking, depending on what you want to track (e.g., the color of the ball).
  3. Set Tracking Options: Configure the tracking options to suit your needs (e.g., color range for the ball).

Step 3: Add the Script for Tracking End

  1. Open Camera Device Configuration: Click on the gear icon of the Camera Device skill to open its configuration.
  2. Go to Scripts Tab: Navigate to the Scripts tab.
  3. Add Tracking End Script: In the Tracking End script section, add the following JavaScript code:
// Define the positions to search for the ball
var positions = [45, 90, 135];

// Function to move the camera to each position
function searchForBall() {
    for (var i = 0; i < positions.length; i++) {
        // Move the camera to the specified position
        Servo.setPosition(D9, positions[i]);

        // Wait for a short duration to allow the camera to move
        sleep(500);
    }
}

// Start searching for the ball
searchForBall();

Step 4: Test the Setup

  1. Run the Project: Start your ARC project and ensure all skills are connected and configured correctly.
  2. Test Object Tracking: Move the ball in and out of the camera's view to see if the camera follows the ball and searches for it when it goes out of view.

Troubleshooting

  • Variable Not Defined: Ensure you are using the correct variable names. For object tracking, use $ObjectTrackingDetected.
  • Servo Movement: Ensure the servo is connected to the correct port (e.g., D9) and is functioning properly.

By following these steps, your Roli Rover should be able to move the camera to search for the ball when it goes out of view. If you encounter any issues, please provide error messages or behavior details, and I'll be happy to assist further.


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
#9  

i got the error message by running the script that the ControlCommand with parameter SetPosition 45,90  is not supported .I attach some photos, it may help for solving my problem..

User-inserted image

User-inserted image

User-inserted image

User-inserted image

User-inserted image

User-inserted image

PRO
Germany
#10  

@Athena  @DJ_Sures . Many thanks, it is working now. I just added more positions for the variable "var". 45-90-135 was too fast. Now the scan object is smoother.

#11   — Edited

Excellent! Glad to hear DJ was helpful to get this working for you

PRO
Synthiam
#12  

Great to hear. I have an idea for the script addition. It current runs forever until the object is detected. Maybe it only needs to run for 5 seconds or something.

@athena can you alter the script so it runs for 5 seconds? Also add more 11 positions to the array.


// Define the positions to search for the ball
var positions = [45, 90, 135];

// Function to move the camera to each position
function searchForBall() {
    for (var i = 0; i < positions.length; i++) {
        // Move the camera to the specified position
        Servo.setPosition(D9, positions[i]);

        // Wait for a short duration to allow the camera to move
        sleep(500);
    }
}

// Start searching for the ball
searchForBall();
PRO
Canada
#13  

Sure, DJ! Let's enhance the script to run for 5 seconds and add more positions to the array for a smoother scan. Here's the updated script:

// Define the positions to search for the ball
var positions = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180];

// Function to move the camera to each position
function searchForBall() {
    var startTime = new Date().getTime();
    var currentTime = startTime;
    var duration = 5000; // 5 seconds

    while (currentTime - startTime < duration) {
        for (var i = 0; i < positions.length; i++) {
            // Move the camera to the specified position
            Servo.setPosition(D9, positions[i]);
            // Wait for a short duration to allow the camera to move
            sleep(500);
            // Update the current time
            currentTime = new Date().getTime();
            // Check if the object is detected
            if (getVar("$ObjectTrackingDetected") == 1) {
                return; // Exit the function if the object is detected
            }
        }
    }
}

// Start searching for the ball
searchForBall();

Explanation:

  1. Positions Array: Added more positions to the array for a smoother scan.
  2. Duration: The script will run for 5 seconds (duration = 5000 milliseconds).
  3. Time Check: The script checks the elapsed time and stops after 5 seconds.
  4. Object Detection: The script checks if the object is detected ($ObjectTrackingDetected == 1) and exits the function if the object is found.

How to Use:

  1. Add the Script: Add this script to the Tracking End script section in the Camera Device configuration.
  2. Run the Project: Start your ARC project and ensure all skills are connected and configured correctly.
  3. Test Object Tracking: Move the ball in and out of the camera's view to see if the camera follows the ball and searches for it when it goes out of view.

This should make the camera's search for the ball smoother and more efficient. If you encounter any issues, please let me know!


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
#14  

@athena i removed following text otherwise we got an error with a variable not found: if (getVar("$ObjectTrackingDetected") == 1) { return; // Exit the function if the object is detected } . i will play a little bit with tilt servo just for fun .thx again

PRO
Canada
#15  

I'm glad to hear you're making progress! If you encountered an error with the variable not found, it might be because the $ObjectTrackingDetected variable wasn't set up in your project. However, removing that part is fine if it works for you.

If you want to add some fun with the tilt servo, you can modify the script to include both pan and tilt movements. Here's an updated version that includes tilt movements:

// Define the positions to search for the ball
var panPositions = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180];
var tiltPositions = [60, 75, 90, 105, 120]; // Add tilt positions

// Function to move the camera to each position
function searchForBall() {
    var startTime = new Date().getTime();
    var currentTime = startTime;
    var duration = 5000; // 5 seconds

    while (currentTime - startTime < duration) {
        for (var i = 0; i < panPositions.length; i++) {
            for (var j = 0; j < tiltPositions.length; j++) {
                // Move the camera to the specified pan and tilt positions
                Servo.setPosition(D9, panPositions[i]); // Pan servo
                Servo.setPosition(D10, tiltPositions[j]); // Tilt servo

                // Wait for a short duration to allow the camera to move
                sleep(500);

                // Update the current time
                currentTime = new Date().getTime();
            }
        }
    }
}

// Start searching for the ball
searchForBall();

Explanation:

  1. Pan and Tilt Positions: Added an array for tilt positions.
  2. Nested Loops: The script now includes nested loops to iterate through both pan and tilt positions.
  3. Servo Movements: Moves both the pan and tilt servos to the specified positions.

How to Use:

  1. Add the Script: Add this script to the Tracking End script section in the Camera Device configuration.
  2. Run the Project: Start your ARC project and ensure all skills are connected and configured correctly.
  3. Test Object Tracking: Move the ball in and out of the camera's view to see if the camera follows the ball and searches for it when it goes out of view.

This should add some fun by making the camera move in both pan and tilt directions while searching for the ball. 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.