-
Posts
22 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Everything posted by bluatigro
-
the IDE complains over the rem's it is translated from c++ throu basic i can not test this let me know if you got it working ''' bluatigro 14 nov 2021 ann try based on : http://code.activestate.com/recipes/578148-simple-back-propagation-neural-network-in-python-s/ ''' import random , math # consts NI = 2 # number of inputs NH = 2 # number of hidden cels NO = 1 # number of outputs # cels ai = list() for i in range( NI ) : ai.append( 0.0 ) ah = list() for h in range( NH ) : ah.append( 0.0 ) ao = list() for o in range( NO ) : ao.append( 0.0 ) # wished output wish = list() for w in range( NO ) : wish.append( 0.0 ) # weights wih = list() ci = list() for i in range( NI ) : wih[ i ] = list() ci[ i ] = list() for h in range( NH ) : wih[ i ].append( random.random() ) ci[ i ].append( random.random() ) who = list() co = list() for h in range( NH ) : who[ h ] = list() co( h ) = list() for o in range( NO ) : who[ h ].append( random.random() ) co[ h ].append( random.random() ) od = list() hd = list() for h in range( NH ) : od.append( random.random() ) hd.append( random.random() ) # input output training data : XOR function paterns = 4 pin = {{0.0,0.0},{1.0,0.0},{0.0,1.0},{1.0,1.0}} pout = { 0.0 , 1.0 , 1.0 , 0.0 } def tanh( x ) : return ( 1 - math.exp( -2 * x ) ) \ / ( 1 + math.exp( -2 *x ) ) def dsignoid( x ) : return 1 - x * x def calc( p ) : for i in range( NI ) : ai[ i ] = pin[ i ][ p ] for h in range( NH ) : som = 0.0 for i in range( NI ) : som += ai[ i ] * wih[ i ][ h ] ah[ h ] = tanh( som / NI ) for o in range( NO ) : som = 0.0 for h in range( NH ) : som += ah[ h ] * who[ h ][ o ] ao[ o ] = tanh( som / NH ) def backprop( n , m ) : ''' http://www.youtube.com/watch?v=aVId8KMsdUU&feature=BFa&list=LLldMCkmXl4j9_v0HeKdNcRA calc output deltas we want to find the instantaneous rate of change of ( error with respect to weight from node j to node k) output_delta is defined as an attribute of each ouput node. It is not the final rate we need. To get the final rate we must multiply the delta by the activation of the hidden layer node in question. This multiplication is done according to the chain rule as we are taking the derivative of the activation function of the ouput node. dE/dw[j][k] = (t[k] - ao[k]) * s'( SUM( w[j][k]*ah[j] ) ) * ah[j] ''' totfout = 0 for k in range( NO ) : totfout += math.abs( ao( k ) - wish( k ) ) # update output weights for j in range( NH ) : for k in range( NO ) # output_deltas[k] * self.ah[j] # is the full derivative of # dError/dweight[j][k] c = od[ k ] * ah[ j ] wo[ j ][ k ] += n * c + m * co[ j ][ k ] co[ j ][ k ] = c # calc hidden deltas for j in range( NH ) : fout = 0 for k in range( NO ) : fout += od[ k ] * wo[ j ][ k ) hd[ j ] = fout * dsignoid( ah[ j ] ) # update input weights for i in range( NI ) : for j in range( NH ) : c = hd[ j ] * ai[ i ] wi[ i ][ j ] += n * c + m * ci[ i ][ j ] ci[ i ][ j ] = c return totfout / 2 for e in range( 10000 ) : fout = 0 # fill input cel's for p in range( paterns ) : for i in range( NH ) : ai[ i ] = pin[ i ][ p ] # fill output wish for o in range( NO ) : wish[ o ] = pout[ p ] fout += backprop( .5 , .5 ) print( 'generatie ' , e , ' error ' , fout )
-
some python for 51515
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
i can not find the to python button and the book button -
some python for 51515
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@lok24 : thanks for the 'book' sugestion i wil look into that -
some python for 51515
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
#create objects dist = DistanceSensor( 'E' ) color = ColorSensor( 'F' ) #read examples darkness = color.get_reflected_light() color.wait_for_color( 'red') dist.wait_for_distance_closer_then( 10 , 'cm' ) hub.moition_sensor.wait_for_new_gesture( 'tapped' ) -
51515 + usb ?
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
i fond the folowing site about python for 51515 : LEGO Mindstorms 51515 Micropython tutorial : mindstorms (reddit.com) but i can not use it because of little char's -
51515 + usb ?
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
i m looking for the translation from scratch into python of the lego specific comands python i do know partly now if you help me whit lego-python i wil post advanced python code i have a code for neural network whit 1 hidden layer in native python [ for example ] i do not know every thing of python but i know OOP in it i know that you can translate scratch code lines into python but i do not know jet how to do that in the IDEapp i m a member of hcc AI groop -
51515 + usb ?
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
on my new pc it went good on my old pc i needed a drive account [ $9.99] so i did not do that [ i do not have a credidcard ] so i wil onlky use my new pc for the 51515 are there python examples for 51515 on the web ? whit python i can enlarge the char's in the ide -
51515 + usb ?
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
thanks for help where can i find the app vor the 51515 -
has the central hub of the 51515 a usb port ? i do not want to use bluetooth
-
i wood like to have a script language in ev3 mindstorms ide whit [ at least ] : loops , choises , recursion , arrays , subs , functions , file i/o [ on brick ] , include and random OOP wil be nice but is not nessesery i don't care whitch language i m a c++ , python and basic programmer [ i don't get payed ] [ basic i do from 1988 so that has my biggest suport ]
-
i had some wadering done on www en fond www.makecode.org this is a site whit several mirco controlers controled by a kind of scratch you can also program in javasrcipt i made the folowing js code [ not tested jet ] let move = "wait"; sensors.remoteButtonTopLeft.onEvent(ButtonEvent.Pressed, function () { move = "turn left" }) sensors.remoteButtonTopRight.onEvent(ButtonEvent.Pressed, function () { move = "forwart" }) sensors.remoteButtonBottomLeft.onEvent(ButtonEvent.Pressed, function () { move = "turn right" }) sensors.remoteButtonBottomRight.onEvent(ButtonEvent.Pressed, function () { move = "backwart" }) motors.stopAll() forever(function () { switch (move) { case "turn left": motors.largeBC.tank(-50, 50) break case "forwart": motors.largeBC.tank(50, 50) break case "turn right": motors.largeBC.tank(50, -50) break case "backwart": motors.largeBC.tank(-50, -50) break default: motors.stopAll() break } control.waitMicros(100) move = "wait" })
-
i m planning a mecrano weeled robot the robot wil be smaller that the one you are oplanning the [ remote ] control program in ev3-g is al ready but not tested
- 101 replies
-
- EV3
- Mindstorms
-
(and 2 more)
Tagged with:
-
[HELP] Need Help with Lejos
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
update : i have lejos SD card i have eclipse eclipse has lejos menu eclipse not showing lejos lib in left part of screen but only java i tryed booting my brick whit SD card : it took a hour and stil led was red what is my next step ? -
[HELP] Need Help with Lejos
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
update : lejos on SD is now good eclipse on new laptop eclipse on old laptop not good jet : google gives differend result's on old and new laptop verry strange !! next problem : if i do eclipse > file > new java project nothing happens visably if i do hello wolrd i see my first project but dont see any code i can not type in the code window and can not find where i can enlarge the code font any help is welkome -
[HELP] Need Help with Lejos
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@dr spock + jim : i tryed SD formater on my old laptop it does not see my SD the port is visable in my pc i see a port but not a thick line whit a part of blue i hope this is the only problem i have to solve if i instal lejos the SD help shows a black screen whit : "no SD card" or somthing like that -
i m trying to get lejos to work everything exept 1 thing is til now good i can not format my SD my windows 10 does not see it i m learing whit the WWW whit some examples i made this : import lejos.hardware.lcd.LCD ; public class Tank_remote { static EV3IRSensor ir = new EV3IRSensor( SensorPort.S4 ) ; static TankRobot tank = new TankRobot() ; public static void main( String [] args ) { LCD.drawString( "Tank remote ." , 2 , 3 ) ; while ( true ) { tank.delay( 40 ) ; byte [] cmd = new byte [ 4 ] ; ir.getRremoteComands( cmd , 0 , cmd.length ) ; if ( cmd[0] == 1 ) tank.move( 100 ) ; else if ( cmd[0] == 2 ) tank.move( -100 ) ; else if ( cmd[0] == 3 ) tank.turn( 100 ) ; else if ( cmd[0] == 4 ) tank.turn( -100 ) ; else tank.tlf() ; } ir.close() ; tank.close() ; } } import lelos.hardware.* ; import lejos.hardware.motor ; import lejos.hardware.port ; import lejos.hardware.sensor ; import lejos.robotics.* ; import lejos.utility.Delay ; public class TankRobot { static EV3LargeRegulatedMotor MB = new EV3largeRegulatedMotor( MotorPort.B ) ; static EV3LargeRegulatedMotor MC = new EV3largeRegulatedMotor( MotorPort.C ) ; static EV3IRSensor IRS = new EV3IRSensor( SensorPort.S4 ) ; static SensorMode distMode ; static RangeFinderAdapter RFA ; static EV3ColorSensor CS = new EV3ColorSensor( SensorPort.S1 ) ; static ColorAdapter CA ; /** * TankRobot() * constructor */ public TankRobot() { distMode = IR.getMode( "distance" ) ; RFA = new RangeFinderAdapter( distMode ) ; CA = new ColorAdapter( CS ) ; } /** * getColor() * @return Color */ public Color getColor() { return CA.getColor() } /** * getDistance() * @return disance in double cm . */ public double getDistance() { return RFA.range() ; } /** * delay( ms ) * @param ms : int milliseconds . */ public void delay( int ms ) { Delay.msDelay( ms ) ; } /** * setMotors( b , c ) * @param b : int set speed motor at port b . * @param c : int set speed motor at port c . */ public void setMotors( int b , int c ) { // set motor B if ( b < 0 ) { MB.setSpeed( -b ) ; MB.backwart() ; } else if ( b > 0 ) { MB.setSpeed( b ) ; MB.forwart() ; } else MB.flt() ; // set motor C if ( c < 0 ) { MC.setSpeed( -c ) ; MC.backwart() ; } else if ( c > 0 ) { MC.setSpeed( c ) ; MC.forwart() ; } else C.flt() ; } /** * move( speed ) * @param speed : set speed both motors same . */ public void move( int i ) { setMotors( i , i ) ; } /** * turn( speed ) * @param speed : set speed both motors different . */ public void turn( int i ) { setMotors( i , -i ) ; } /** * flt() * slow down and stop . */ public void flt() { setMotors( 0 , 0 ) ; } /** * stop() * stop motors . */ public void stop() { MB.stop() ; MC.stop() ; } /** * close() * close all motors and sensors . */ public void close() ; { MB.close() ; MA.close() ; IRS.close() ; CS.close() ; } } does this look good ? if error's : please point them out
-
ev3 basic users here ?
bluatigro replied to bluatigro's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
i tryed to create a dark line folow program [MOC] the light on the ev3brick reacts as expected but the motor''s not what can be wrong ? '' bluatigro 3 may 2018 '' dark line follow '' volg donkere lijn '' robot wil follow a dark line '' robot volgt een donkere lijn '' const's init '' constanten init colport = 1 colreflect = 0 ''readpercent colambient = 1 ''readpercent colcolor = 2 ''readrawvalue rgbraw = 4 ''readraw irport = 4 irproc = 0 ''readpercent = cm irseek = 1 ''readraw = angle , dist irremote = 2 ''readraw[ 0 ... 3 ] = channel[ 1 ... 4 ] Sensor.SetMode( colport , colreflect ) Sensor.SetMode( irport , irremote ) EV3.SetLEDColor( "ORANGE" , "PULSE" ) irkey = Sensor.ReadRaw( irport ) While irkey( 0 ) <> 3 And irkey( 0 ) <> 4 irkey = Sensor.ReadRaw( irport ) EndWhile EV3.SetLEDColor( "GREEN" , "PULSE" ) ' main lus | loop While irkey( 0 ) <> 1 And irkey( 0 ) <> 2 light = Sensor.ReadPercent( colport ) irkey = Sensor.ReadRaw( irport ) If light < 20 Then Motor.MoveSteer( "bc" , -15 , 75 , 30 , "false" ) Else Motor.MoveSteer( "bc" , 75 , -15 , 30 , "false" ) EndIf EndWhile -
are there here users of ev3basic here ? i m a great fan of basic [ i use it +-33y ] the only problem is that in smal basic the char's of the IDE can not be bigger i got the following working test.sb : a = Buttons.Current EV3.SetLEDColor( "ORANGE" , "PULSE" ) While a <> "U" a = Buttons.Current EV3.SetLEDColor( "GREEN" , "NORMAL" ) Program.Delay( 500 ) EV3.SetLEDColor( "RED" , "NORMAL" ) Program.Delay( 500 ) EndWhile EV3.SetLEDColor( "ORANGE" , "PULSE" )