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.