To jest stara wersja strony!


Opis

Marek, Siara, siara@student.agh.edu.pl

:!: Multilayer Stack in Prolog idea:

  • Serial Comm.(USB/BT)
  • low-level Prolog api 4 serial port, NXT comm. protocol, see other envs
  • mid-level NXT abstraction

see MindStormsAPI for other higher levels.

Spotkania

08.03.04

080311

protokół na poziomie kom. po porcie szeregowym http://nxtpp.sourceforge.net/

080318

080401

080408

  • zapis protokołu kom w prologu tak jak poniżej
  • upload do wiki opisu FIXME
  • testy komunikacji, flush?
  • zapis szesnastkowy w ISO Prologu, proszę się upewnić, że to (hexy) się

już nigdzie nie gubi przy ew. konwersji…

% uwaga!
% komp w pldoc!
% http://www.swi-prolog.org/packages/pldoc.html
% przemyslec, co da uzycie skladni wiki!

% czy porty dla sensorow sa abcd, czy 1,2,3,4?
nxt_port(a,['\x00\']).
% etc

dla serwo 0, 1, 2, sensory do sprawdzenia.

nxt_sensor_type(no_sensor, ['\x00\']).
nxt_sensor_type(switch, ['\x01\']).
nxt_sensor-type(temperature, ['\x02\']).
nxt_sensor-type(reflection, ['\x03\']).
nxt_sensor-type(angle, ['\x04\']).
nxt_sensor-type(light_active, ['\x05\']).
nxt_sensor-type(light_inactive, ['\x06\']).
nxt_sensor-type(sound_db, ['\x07\']).
nxt_sensor-type(sound_dba, ['\x08\']).
nxt_sensor-type(custom, ['\x09\']).
nxt_sensor-type(low_speed, ['\x0A\']).
nxt_sensor-type(low_speed_9v, ['\x0B\']).
nxt_sensor-type(no_of_sensor_types, ['\x0C\']).

nxt_sensor_mode(rawmode, ['\x00\']).
nxt_sensor_mode(booleanmode, ['\x20\']).
nxt_sensor_mode(transitioncntmode, ['\x40\']).
nxt_sensor_mode(periodcountermode, ['\x60\']).
nxt_sensor_mode(pctfullscalemode, ['\x80\']).
nxt_sensor_mode(celciusmode, ['\xA0\']).
nxt_sensor_mode(fahrenheitmode, ['\xC0\']).
nxt_sensor_mode(anglestepmode, ['\xE0\']).
nxt_sensor_mode(slopemask, ['\x1F\']).
nxt_sensor_mode(modemask, ['\xE0\']). % zbieżność z drugim powyżej, co z tym zrobić ?

nxt_mode(motoron, ['\x01\']).
nxt_mode(brake, ['\x02\']).
nxt_mode(regulated, ['\x04\']).

nxt_regulation_mode(regulation_mode_idle, ['\x00\']).
nxt_regulation_mode(regulation_mode_motor_speed, ['\x01\']).
nxt_regulation_mode(regulation_mode_motor_syns, ['\x02\']).

nxt_run_state(motor_run_state_idle, ['\x00\']).
nxt_run_state(motor_run_state_rampup, ['\x10\']).
nxt_run_state(motor_run_state_running, ['\x20\']).
nxt_run_state(motor_run_state_rampdown, ['\x40\']).

nxt_cmd(startprogram, ['\x00\','\x00\']). % czy dopisać wszędzie nxt_cmd(Cmd, ['\x80\',_]).  ???
nxt_cmd(stopprogram, ['\x00\','\x01\']).
nxt_cmd(playsoundfile, ['\x00\','\x02\']).
nxt_cmd(playtone, ['\x00\','\x03\']).
nxt_cmd(setoutputstate, ['\x00\','\x04\']).  
nxt_cmd(setinputmode, ['\x00\','\x05\']).
nxt_cmd(messagewrite, ['\x00\','\x09\']).
nxt_cmd(resetmotorposition,['\x00\','\x0A\']).

%% nxt_prot(+Command, -NxtCmd, +Port, +Type, +Mode)

nxt_prot(setoutputstate, NxtCmd, Port, PowerSetPoint, Mode, RegulationMode, TurnRatio, RunState, TachoLimit) :-
	nxt_cmd(setoutputstate,Cmd),
	nxt_port(Port, PortCmd),
	integer(PowerSetPoint), PowerSetPoint >= -100, PowerSetPoint < 101,
	nxt_mode(Mode, ModeCmd),
	nxt_regulation_mode(RegulationMode, RegulationModeCmd),
	integer(TurnRatio), TurnRatio >= -100, TurnRatio < 101,
	nxt_run_state(RunState, RunStateCmd),
	TachoLimit < (5B value ?).

% return a nxt command with a given port, type, and mode (for setinputmode)
nxt_prot(setinputmode, NxtCmd, Port, Type, Mode) :-
	nxt_cmd(setinputmode,Cmd),
	nxt_port(Port, PortCmd),
	nxt_sensor_type(Type, TypeCmd),
	nxt_sensor_mode(Mode, ModeCmd),
	flatten([Cmd, PortCmd,TypeCmd,ModeCmd],NxtCmd).

nxt_prot(messagewrite, NxtCmd, Inbox, Size,Data) :-
	nxt_cmd(messagewrite,Cmd),
	integer(Inbox), Inbox < 10, Inbox >= 0,
	length(Data,L),
	Size is L + 3,
	Size < 60, % vide doc!
	flatten([Cmd,Inbox,Size,Data],NxtCmd).

% tu nalezy jeszcze sprawdzic null termination vide dokuemntacja, ew dodac jak go nie ma!

% nxt_prot(setinputmode,C,a,switch,rawmode).
% nxt_prot(messagewrite,C,3,S,['a','l','a']).
% nxt_prot(messagewrite,C,3,_,['a','l','a']).

% aha, prosze przemyslec i potestowac, czy nie wystarczy powyzej pisac:
% nxt_prot(COSTAM, NxtCmd, Inbox, Size,Data) :-
%	nxt_cmd(COSTAM,Cmd),
% na oko chyba tak!

FIXME :pl:miw:appendix_2-lego_mindstorms_nxt_direct_commands.pdf

FIXME: proszę dopisać URL gdzie za strony LEGO Pan to pobrał, czy to jest w BT dev guide?

Projekt

Milestones

  • komunikacja z nxt z prolog, potrafimy wyslac trywialne rozkazy, np. obroc silniczkem nr. 2

Sprawozdanie

W związku z tym, że materiały podane poniżej były mało ciekawe, a na stronie producenta ciężko jest cokolwiek znaleźć, zapoznałem się z dokumentacją techniczną i zasadą działania standardu USB. Mam nadzieję, że ta wiedza będzie pomocna, ponieważ poznawanie standardu USB było uciążliwe. Wiele jest ciekawych materiałów w sieci, po przeczytaniu skrócony opis zamieściłem w http://student.agh.edu.pl/~siara/USB.pdf

Materiały

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