Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Both sides previous revision Poprzednia wersja
Nowa wersja
Poprzednia wersja
pl:miw:miw08_mindstormscontrols [2008/04/07 20:28]
miw
pl:miw:miw08_mindstormscontrols [2019/06/27 15:50] (aktualna)
Linia 27: Linia 27:
  
  
 +===== 080408 =====
 +  * zapis protokołu kom w prologu tak jak poniżej
 +  * upload do wiki opisu FIXME
 +  * testy komunikacji,​ flush?
 +  * [[https://​akela.mendelu.cz/​swi-prolog/​syntax.html|zapis szesnastkowy w ISO Prologu]], proszę się upewnić, że to (hexy) się już nigdzie nie gubi przy ew. konwersji...
  
 +===== 080415 =====
 +  * test komunikacji!!!!!!!
 +  * całośc kom 2 kier na kilku poleceniach
  
  
 +====== Projekt ======
  
 +<​code>​
  
 +% C = getbatterylevel
 +%nxt_com(getbatterylevel,​ Ret) 
  
 +nxt_com(C) :- 
 +%  nxt_open(Fd),​
 +  nxt_prot(C, NxtCmd, RL), %Rl=4 bl
 +  nxt_send(Fd,​NxtCmd),​
 +  nxt_recv(Fd,​RL,​Resp),​
 +  nxt_resp(C, Resp, X). % X = VLMV
  
-===== 080408 ===== +%nxt_open(Fd) :- 
-  * zapis protokołu kom w prologu tak jak poniżej +% 
-  * upload do wiki opisu FIXME +nxt_send(Fd,NxtCmd) ​:- 
-  * testy komunikacjiflush? + 
-  * [[https://​akela.mendelu.cz/​swi-prolog/​syntax.html|zapis szesnastkowy w ISO Prologu]]proszę się upewnić, że to (hexysię +nxt_recv(Fd,R) :- 
-już nigdzie nie gubi przy ew. konwersji...+ 
 +nxt_resp(getbatterylevel
 +</​code>​
  
 <​code>​ <​code>​
Linia 48: Linia 68:
  
 % czy porty dla sensorow sa abcd, czy 1,2,3,4? % czy porty dla sensorow sa abcd, czy 1,2,3,4?
-nxt_port(a,​['​\x00\'​]). 
-% etc 
- 
 </​code>​ </​code>​
-dla serwo 012, sensory do sprawdzenia.+Z dokumentacji:​ 
 +  * Byte 2: Output port (Range: ​- 2) 
 +  * Byte 2: Input port (Range: 0 - 3) 
 + 
 +Z nxt++: 
 +  * Motor  A - 0; 
 +  * Motor  B - 1; 
 +  * Motor  C - 2; 
 +  * Sensor 1 - 0; 
 +  * Sensor 2 - 1
 +  * Sensor 3 - 2
 +  * Sensor 4 - 3;
 <​code>​ <​code>​
 +% póki co:
 +nxt_port(0,​['​\x00\'​]). % sprawdzić!
 +nxt_port(1,​['​\x01\'​]).
 +nxt_port(2,​['​\x02\'​]).
  
 nxt_sensor_type(no_sensor,​ ['​\x00\'​]). nxt_sensor_type(no_sensor,​ ['​\x00\'​]).
Linia 92: Linia 124:
 nxt_run_state(motor_run_state_running,​ ['​\x20\'​]). nxt_run_state(motor_run_state_running,​ ['​\x20\'​]).
 nxt_run_state(motor_run_state_rampdown,​ ['​\x40\'​]). nxt_run_state(motor_run_state_rampdown,​ ['​\x40\'​]).
 +
 +% w nxt++ nie wysyłają na początku bajtu zerowego, to byłoby logiczne, ponieważ zawsze na początku będzie startprogram... :
  
 nxt_cmd(startprogram,​ ['​\x00\','​\x00\'​]). % czy dopisać wszędzie nxt_cmd(Cmd,​ ['​\x80\',​_]). ​ ??? nxt_cmd(startprogram,​ ['​\x00\','​\x00\'​]). % czy dopisać wszędzie nxt_cmd(Cmd,​ ['​\x80\',​_]). ​ ???
Linia 99: Linia 133:
 nxt_cmd(setoutputstate,​ ['​\x00\','​\x04\'​]).  ​ nxt_cmd(setoutputstate,​ ['​\x00\','​\x04\'​]).  ​
 nxt_cmd(setinputmode,​ ['​\x00\','​\x05\'​]). nxt_cmd(setinputmode,​ ['​\x00\','​\x05\'​]).
 +nxt_cmd(getoutputstate,​ ['​\x00\','​\x06\'​]).
 +nxt_cmd(getinputvalues,​ ['​\x00\','​\x07\'​]).
 +nxt_cmd(resetinputscaledvalue,​ ['​\x00\','​\x08\'​]).
 nxt_cmd(messagewrite,​ ['​\x00\','​\x09\'​]). nxt_cmd(messagewrite,​ ['​\x00\','​\x09\'​]).
-nxt_cmd(resetmotorposition,​['​\x00\','​\x0A\'​]).+nxt_cmd(resetmotorposition,​ ['​\x00\','​\x0A\'​]). 
 +nxt_cmd(getbatterylevel,​ ['​\x00\','​\x0B\'​]). 
 +nxt_cmd(stopsoundplayback,​ ['​\x00\','​\x0C\'​]). 
 +nxt_cmd(keepalive,​ ['​\x00\','​\x0D\'​]). 
 +nxt_cmd(lsgetstatus,​ ['​\x00\','​\x0E\'​]). 
 +nxt_cmd(lswrite,​ ['​\x00\','​\x0F\'​]). 
 +nxt_cmd(lsread,​ ['​\x00\','​\x10\'​]). 
 +nxt_cmd(getcurrentprogramname,​ ['​\x00\','​\x11\'​]). 
 +nxt_cmd(messageread,​ ['​\x00\','​\x12\'​]). 
 + 
 +%% nxt_prot(+Command,​ -NxtCmd, +Port, +Type, +Mode, +Etc) 
 + 
 +nxt_prot(startprogram,​ NxtCmd, FileName) :- 
 + nxt_cmd(startprogram,​Cmd),​ 
 +
 + 
 +nxt_prot(stopprogram,​ NxtCmd) :- 
 + nxt_cmd(stopprogram,​ Cmd), 
 + flatten([Cmd],​ NxtCmd). 
 + 
 +nxt_prot(playsoundfile,​ NxtCmd, Loop, FileName) :- 
 + nxt_cmd(playsoundfile,​ Cmd), 
 + boolean(Loop),​ 
 + LoopCmd = Loop, 
 + ?
  
-%% nxt_prot(+Command-NxtCmd, ​+Port+Type, +Mode)+nxt_prot(playtone, NxtCmd, ​FrequencyDuration) :- 
 + nxt_cmd(playtoneCmd), 
 + FrequencyCmd1 is Frequency mod 256, 
 + FrequencyCmd2 is (Frequency - (Frequency mod 256)) / 256, % wzięte z nxt+
 + DurationCmd1 is Duration mod 256, 
 + DurationCmd2 is (Duration - (Duration mod 256)) / 256, 
 + flatten([Cmd,​ FrequencyCmd1,​ FrequencyCmd2,​ DurationCmd1,​ DurationCmd2],​ NxtCmd). % <- poprawić na listy!
  
 nxt_prot(setoutputstate,​ NxtCmd, Port, PowerSetPoint,​ Mode, RegulationMode,​ TurnRatio, RunState, TachoLimit) :- nxt_prot(setoutputstate,​ NxtCmd, Port, PowerSetPoint,​ Mode, RegulationMode,​ TurnRatio, RunState, TachoLimit) :-
Linia 112: Linia 179:
  integer(TurnRatio),​ TurnRatio >= -100, TurnRatio < 101,  integer(TurnRatio),​ TurnRatio >= -100, TurnRatio < 101,
  nxt_run_state(RunState,​ RunStateCmd),​  nxt_run_state(RunState,​ RunStateCmd),​
- TachoLimit < (5B value ?).+ TachoLimit < (5B value ?), 
 + flatten([Cmd,​ Port, PowerSetPoint,​ Mode, RegulationMode,​ TurnRatio, RunState, TachoLimit],​ NxtCmd).
  
 % return a nxt command with a given port, type, and mode (for setinputmode) % return a nxt command with a given port, type, and mode (for setinputmode)
Linia 121: Linia 189:
  nxt_sensor_mode(Mode,​ ModeCmd),  nxt_sensor_mode(Mode,​ ModeCmd),
  flatten([Cmd,​ PortCmd,​TypeCmd,​ModeCmd],​NxtCmd).  flatten([Cmd,​ PortCmd,​TypeCmd,​ModeCmd],​NxtCmd).
 +
 +nxt_prot(getoutputstate,​ NxtCmd, Port) :-
 + nxt_cmd(getoutputstate,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + flatten([Cmd,​ PortCmd], NxtCmd).
 +
 +nxt_prot(getinputvalues,​ NxtCmd, Port) :-
 + nxt_cmd(getinputvalues,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + flatten([Cmd,​ PortCmd], NxtCmd).
 +
 +nxt_prot(resetinputscaledvalue,​ NxtCmd, Port) :-
 + nxt_cmd(resetinputscaledvalue,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + flatten([Cmd,​ PortCmd], NxtCmd).
  
 nxt_prot(messagewrite,​ NxtCmd, Inbox, Size,Data) :- nxt_prot(messagewrite,​ NxtCmd, Inbox, Size,Data) :-
Linia 129: Linia 212:
  Size < 60, % vide doc!  Size < 60, % vide doc!
  flatten([Cmd,​Inbox,​Size,​Data],​NxtCmd).  flatten([Cmd,​Inbox,​Size,​Data],​NxtCmd).
 +
 +nxt_prot(resermotorposition,​ NxtCmd, Port, IsRelative) :-
 + nxt_cmd(resermotorposition,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + boolean(IsRelative),​
 + IsRelativeCmd = IsRelative,
 + flatten([Cmd,​ , PortCmd, IsRelativeCmd],​ NxtCmd).
 +
 +nxt_prot(getbatterylevel,​ NxtCmd) :-
 + nxt_cmd(getbatterylevel,​ Cmd),
 + flatten([Cmd],​ NxtCmd).
 +
 +nxt_prot(stopsoundplayback,​ NxtCmd) :-
 + nxt_cmd(stopsoundplayback,​ Cmd),
 + flatten([Cmd],​ NxtCmd).
 +
 +nxt_prot(keepalive,​ NxtCmd) :-
 + nxt_cmd(keepalive,​ Cmd),
 + flatten([Cmd],​ NxtCmd).
 +
 +nxt_prot(lsgetstatus,​ NxtCmd, Port) :-
 + nxt_cmd(lsgetstatus,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + flatten([Cmd,​ PortCmd], NxtCmd).
 +
 +nxt_prot(lswrite,​ NxtCmd, Port, TxDataLenght,​ RxDataLength,​ TxData) :-
 + nxt_cmd(lswrite,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + length(TxData,​L),​
 + TxDatalength is L + 4,
 + TxDataLength < (no właśnie, ile?),
 + flatten([Cmd,​ Port, TxDataLength,​ RxDataLength,​ TxData], NxtCmd).
 +
 +nxt_prot(lsread,​ NxtCmd, Port) :-
 + nxt_cmd(lsread,​ Cmd),
 + nxt_port(Port,​ PortCmd),
 + flatten([Cmd,​ PortCmd], NxtCmd).
 +
 +nxt_prot(getcurrentprogramname,​ NxtCmd) :-
 + nxt_cmd(getcurrentprogramname,​ Cmd),
 + flatten([Cmd],​ NxtCmd).
 +
 +nxt_prot(mesageread,​ NxtCmd, RemoteInbox,​ LocalInbox, Remove) :-
 + nxt_cmd(messageread,​ Cmd),
 + integer(RemoteInbox),​ RemoteInbox >= 0, RemoteInbox < 10,
 + integer(LocalInbox),​ LocalInbox >= 0, LocalInbox < 10,
 + boolean(Remove),​
 + RemoveCmd = Remove,
 + flatten([Cmd,​ RemoteInbox,​ LocalInbox, Remove], NxtCmd).
 +
 +
  
 % tu nalezy jeszcze sprawdzic null termination vide dokuemntacja,​ ew dodac jak go nie ma! % tu nalezy jeszcze sprawdzic null termination vide dokuemntacja,​ ew dodac jak go nie ma!
Linia 147: Linia 281:
 FIXME: proszę dopisać URL gdzie za strony LEGO Pan to pobrał, czy to jest w BT dev guide? FIXME: proszę dopisać URL gdzie za strony LEGO Pan to pobrał, czy to jest w BT dev guide?
  
-====== Projekt ======+
 ===== Milestones ===== ===== Milestones =====
   * komunikacja z nxt z prolog, potrafimy wyslac trywialne rozkazy, np. obroc silniczkem nr. 2   * komunikacja z nxt z prolog, potrafimy wyslac trywialne rozkazy, np. obroc silniczkem nr. 2
pl/miw/miw08_mindstormscontrols.1207592921.txt.gz · ostatnio zmienione: 2019/06/27 15:58 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0