PRO
Taubore
Canada
Asked
— Edited
Resolved by Athena AI!
Hi @Athena,
Is it possible to retrieve the read value from the Sharp IR (Radar and/or Distance) skill in Synthiam ARC? I would like to use this data within a Script Skill. If it is possible, could you provide an example script in Python?
Thank you!
Related Hardware EZ-B v4
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
Steps to Implement the Script
Add the Sharp IR Radar and Sharp IR Collision skills to your ARC project:
Project
->Add Skill
->Infrared Distance
->Sharp IR Radar
.Project
->Add Skill
->Infrared Distance
->Sharp IR Collision
.Add a Script skill to your ARC project:
Project
->Add Skill
->Scripting
->Script
.Configure the Sharp IR Radar and Sharp IR Collision skills:
Edit the Script skill:
Run the Script:
Notes
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.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.
@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")
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
Open the Sharp IR Collision Skill Configuration:
Add a Script to Update the Global Variable:
Example Script to Update Global Variable:
$SharpIRCollisionValue
with the sensor's value.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:
Steps to Add and Run the Script
Add a Script Skill to Your ARC Project:
Project -> Add Skill -> Scripting -> Script
.Edit the Script Skill:
Run the Script:
Notes
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.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.
@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.
Thanks!
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
Steps to Use the Script
Add a Script Skill to Your ARC Project:
Project
->Add Skill
->Scripting
->Script
.Edit the Script Skill:
Run the Script:
Notes
adc_port
variable is set to the correct ADC port number where your Sharp IR sensor is connected.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.