ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

PRO
Canada
#1  

Yes, you can retrieve the read value from the Sharp IR Radar and Sharp IR Collision skills in Synthiam ARC and use this data within a Script Skill. Below is an example of how you can achieve this using Python.

Example Script in Python

  1. Add the Sharp IR Radar and Sharp IR Collision skills to your ARC project.
  2. Add a Script skill to your ARC project.
  3. Use the following Python script to retrieve the read value from the Sharp IR Radar and Sharp IR Collision skills.
# Retrieve the value from the Sharp IR Radar skill
# Assuming the Sharp IR Radar skill is named "Sharp IR Radar"
radar_value = getVar("$SharpIRRadarValue")

# Retrieve the value from the Sharp IR Collision skill
# Assuming the Sharp IR Collision skill is named "Sharp IR Collision"
collision_value = getVar("$SharpIRCollisionValue")

# Print the values to the console
print("Sharp IR Radar Value: ", radar_value)
print("Sharp IR Collision Value: ", collision_value)

# Example usage: If the radar value is less than a certain threshold, stop the robot
threshold = 50  # Example threshold value
if radar_value < threshold:
    print("Obstacle detected! Stopping the robot.")
    controlCommand("Movement Panel", "Stop")
else:
    print("Path is clear. Continuing movement.")

Steps to Implement the Script

  1. Add the Sharp IR Radar and Sharp IR Collision skills to your ARC project:

    • Go to Project -> Add Skill -> Infrared Distance -> Sharp IR Radar.
    • Go to Project -> Add Skill -> Infrared Distance -> Sharp IR Collision.
  2. Add a Script skill to your ARC project:

    • Go to Project -> Add Skill -> Scripting -> Script.
  3. Configure the Sharp IR Radar and Sharp IR Collision skills:

    • Ensure that the Sharp IR Radar and Sharp IR Collision skills are properly configured with the correct ADC ports and other settings.
  4. Edit the Script skill:

    • Open the Script skill and paste the provided Python script.
  5. Run the Script:

    • Execute the script to see the values retrieved from the Sharp IR Radar and Sharp IR Collision skills.

Notes

  • Ensure that the names of the skills in the script match the names in your ARC project.
  • The getVar() function is used to retrieve the values of global variables. Make sure the Sharp IR Radar and Sharp IR Collision skills are configured to update these global variables.
  • Adjust the threshold value and other parameters as needed for your specific use case.

If you have any further questions or need additional 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
Canada
#2  

@Athena, you say "Make sure the Sharp IR Collision skills are configured to update these global variables". How do I do this? Right now, the getVar() function returns the value "None" even though I named my skill "Sharp IR Collision" and I used getVar("$SharpIRCollisionValue")

PRO
Canada
#3  

To ensure that the Sharp IR Collision skill updates a global variable, you need to configure the skill to set a global variable with the sensor's value. Here's how you can do it:

Steps to Configure Sharp IR Collision Skill to Update Global Variables

  1. Open the Sharp IR Collision Skill Configuration:

    • In your ARC project, click on the gear icon (settings) of the Sharp IR Collision skill to open its configuration menu.
  2. Add a Script to Update the Global Variable:

    • In the configuration menu, you can add a script that will update a global variable with the sensor's value. This script will be executed every time the sensor reads a new value.
  3. Example Script to Update Global Variable:

    • Use the following script to update the global variable $SharpIRCollisionValue with the sensor's value.
# Assuming the sensor value is stored in a variable named 'sensor_value'
sensor_value = getVar("$ADCValue")  # Replace with the actual variable name if different
setVar("$SharpIRCollisionValue", sensor_value)
  1. Save the Configuration:
    • Save the changes in the configuration menu.

Example Script in Python to Retrieve the Value

Now that the Sharp IR Collision skill is configured to update the global variable, you can use the following Python script in your Script skill to retrieve the value:

# Retrieve the value from the Sharp IR Collision skill
collision_value = getVar("$SharpIRCollisionValue")

# Print the value to the console
print("Sharp IR Collision Value:", collision_value)

# Example usage: If the collision value is less than a certain threshold, stop the robot
threshold = 50  # Example threshold value
if collision_value < threshold:
    Movement.stop()

Steps to Add and Run the Script

  1. Add a Script Skill to Your ARC Project:

    • Go to Project -> Add Skill -> Scripting -> Script.
  2. Edit the Script Skill:

    • Open the Script skill and paste the provided Python script.
  3. Run the Script:

    • Execute the script to see the values retrieved from the Sharp IR Collision skill.

Notes

  • Ensure that the names of the skills in the script match the names in your ARC project.
  • The getVar() function is used to retrieve the values of global variables. Make sure the Sharp IR Collision skill is configured to update these global variables.
  • Adjust the threshold value and other parameters as needed for your use case.

If you have any further questions or need additional 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
Canada
#4  

@Athena, you refer to icon which no longer exists in ARC to open its configuration menu. Then you refer in configuration menu to adding a script which does not exist either. Or, at least, which no longer exists.

I finally found the following solution which consists in reading the ADC pin directly with the following code that I incorporated in my script and I then obtain the desired value.

while True:
  sharp_1 = ADC.Get(0) 
  print("Distance Sharp 1: ", sharp_1)

Thanks!

PRO
Canada
#5  

I apologize for the confusion and outdated information. I'm glad you found a solution that works for you! Reading the ADC pin directly is indeed a straightforward and effective way to get the sensor values. Here's a more detailed example of how you can continuously read the ADC value from the Sharp IR sensor and use it in your script:

Example Script in Python to Continuously Read ADC Value

import time

# Define the ADC port where the Sharp IR sensor is connected
adc_port = 0  # Change this to the correct ADC port number

while True:
    # Read the value from the ADC port
    sharp_1 = ADC.get(adc_port)
    
    # Print the value to the console
    print("Distance Sharp 1:", sharp_1)
    
    # Add a delay to avoid flooding the console with too many messages
    time.sleep(0.5)  # Adjust the delay as needed

Steps to Use the Script

  1. Add a Script Skill to Your ARC Project:

    • Go to Project -> Add Skill -> Scripting -> Script.
  2. Edit the Script Skill:

    • Open the Script skill and paste the provided Python script.
  3. Run the Script:

    • Execute the script to see the values retrieved from the Sharp IR sensor.

Notes

  • Ensure that the adc_port variable is set to the correct ADC port number where your Sharp IR sensor is connected.
  • Adjust the time.sleep() delay as needed to control the frequency of readings.

This approach directly reads the ADC value from the specified port and prints it to the console, allowing you to use the sensor data in your script.

If you have any further questions or need additional 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.