GLOBAL SITE AUSTRALIAN SITE

List not allowed here | EdPy Programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
List not allowed here
May 29, 2018
4:04 am
Julien Barbet
New Member
Members
Forum Posts: 1
Member Since:
June 15, 2017
sp_UserOfflineSmall Offline

Hello,

First, excuse me for my poor english.

I’m a french teacher and I want to use my Edison in my classroom (childs from 3 to 5 years). The idea : controlling the Edison with a remote to move it on a grid set on the floor (from the start square to goal square).

I need 4 instructions (forward, backward, rotate left + forward, rotate right+ forward). These instructions are stored in a list and another remote button launches the execution of the list.

I have a problem with the list that I use to store the instructions.

commands = [];  Syntax error, List not allowed here

Here is my code :

#————-Setup—————-

import Ed

Ed.EdisonVersion = Ed.V2

Ed.DistanceUnits = Ed.CM
Ed.Tempo = Ed.TEMPO_MEDIUM

#——–Your code below———–

# fonction à laquelle je fais appel dans le prog principal pour faire avancer le robot
def remotePress():
# bip, mise en route des LED
Ed.PlayBeep()
Ed.LeftLed(Ed.ON)
Ed.RightLed(Ed.ON)

# stockage dans rc de la valeur envoyée par la télécommande
# enregistrement dans une liste
rc = Ed.ReadRemote();
commands = []; 
# tant que la touche n’est pas celle correspondant
# à la fin de la série (ici touche 4)
# on enregistre les commandes dans une liste
while rc != Ed.REMOTE_CODE_4:
rc = Ed.ReadRemote();
commands.append(rc);

# parcours des commandes et exécution
for command in commands:
# le robot avance si le code est 0
if (command==Ed.REMOTE_CODE_0):
Ed.Drive(Ed.FORWARD, Ed.SPEED_1, 20)
# le robot recule si le code est 1
if (command==Ed.REMOTE_CODE_1):
Ed.Drive(Ed.BACKWARD, Ed.SPEED_1, 20)
# le robot pivote à droite et avance si le code est 2
if (command==Ed.REMOTE_CODE_2):
Ed.Drive(Ed.SPIN_RIGHT, Ed.SPEED_1,95)
# le robot pivote à gauche et avance si le code est 3
if (command==Ed.REMOTE_CODE_3):
Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_1, 95)

# led éteintes
Ed.LeftLed(Ed.OFF)
Ed.RightLed(Ed.OFF)

Ed.RegisterEventHandler(Ed.EVENT_REMOTE_CODE, “remotePress”)

while True:
Ed.TimeWait(1, Ed.TIME_SECONDS)

Programming is so far from me now… I’m blocked with this error and I’m not sure that the rest of the code is OK frown

Can you help me?

Thanks.

Julien

May 29, 2018
10:15 am
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

Hi

Unfortunately Ed.Py is not a full version of python. 

Ed.Py must be compiled to be programmed into Edison, so Ed.Py cannot use all python syntax.

In this case, Python list structures are invalid, because the compiler need to know how long the list will be before compiling the program.

To create a list please use “Ed.List()”

append() is not a valid function in EdPy because lists have a fixed length as given in the “Ed.List()” function

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This