Asked
Resolved Resolved by Athena AI!

Skill Ultrasonic Distance - Unable To Access It Through Controlcommand

I expected to be able to access the Ultrasonic Distance skill using the ControlCommand, but it doesn't seem possible. Is this normal behavior?

Here are the steps I took:

  1. Added the Ultrasonic Distance skill.
  2. Added the Script skill.
  3. In the Script skill's Cheat Sheet tab, I don't see any instance for Ultrasonic Distance.

The same issue occurs if I right-click in the script editing area. Additionally, in the Global Variables tab, the $PingDistance variable does not appear. I've tried referencing it directly, but I'm obviously getting an error.

Here is my screenshot:

User-inserted image


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Join the ARC Pro community and gain access to a wealth of resources and support, ensuring your robot's success.

PRO
Canada
#1  

It seems like you're trying to access the Ultrasonic Distance skill using the ControlCommand() function in ARC, but you're encountering issues. Let's address your concerns step-by-step.

1. Accessing Ultrasonic Distance Skill via ControlCommand

The ControlCommand() function allows you to send commands to other robot skills within your ARC project. However, not all skills expose commands that can be accessed via ControlCommand(). The Ultrasonic Distance skills you mentioned (Ultrasonic Radar, Ultrasonic Collision Detection, and Ultrasonic Collision Script) may not have specific ControlCommand() functions available.

2. Using Global Variables

For the Ultrasonic Distance skills, the distance values are typically updated in real-time and can be accessed via global variables. However, if the $PingDistance variable is not appearing, it might be due to the specific configuration or the way the skill updates the variable.

Steps to Troubleshoot and Access Distance Values

A. Verify Skill Configuration

  1. Check Skill Settings: Ensure that the Ultrasonic Distance skills are correctly configured with the appropriate ports and intervals.
  2. Pause Checkbox: Make sure the "Pause" checkbox is unchecked in the skill settings to allow real-time updates.

B. Accessing Distance Values in Scripts

  1. Using GetPing() Function: You can use the GetPing() function to manually retrieve the distance value from the ultrasonic sensor. This function can be called within your script to get the latest distance reading.

    var distance = Ping.get(d0, d1); // Replace d0 and d1 with your actual trigger and echo ports
    print("Distance: " + distance);
    
  2. Using Global Variables: If the skill updates a global variable, you can access it using the getVar() function.

    var distance = getVar("$PingDistance");
    print("Distance: " + distance);
    

C. Example Script for Ultrasonic Collision Script

Here is an example script that uses the Ping.get() function to retrieve the distance and perform actions based on the distance value:

// Stop the robot from moving
Movement.stop();

// Speak and let us know what's going on
Audio.say("I see an object");

// Reverse for 2 seconds
Movement.reverse();
sleep(2000);
Movement.stop();

// Set a slow speed for turning
Movement.setSpeed(50);

// Begin turning to the right
Movement.right();

while (true) {
    // Get the latest value from the ultrasonic sensor
    var distance = Ping.get(d0, d1); // Replace d0 and d1 with your actual trigger and echo ports

    // Check if the path is clear
    if (distance > 20) {
        // Stop turning
        Movement.stop();

        // Let us know the path is clear by speaking
        Audio.say("Path is clear");

        // Exit the script
        halt();
    }

    // Pause while we are turning
    sleep(200);
}

Additional Resources

If you continue to experience issues, please provide more details or screenshots of your configuration, 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
Canada
#3  

You're welcome, Taubore! If you have any more questions or need further assistance with your EZ-B v4 or ARC project, feel free to ask. Happy robot building!


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.