ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

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.