=========================================================================== R-CODE for ERS-7 Copyright (C) 2004 Sony Corporation All Rights Reserved. =========================================================================== [ Changes ] [ R-CODE Coding Conventions ] [ List of R-CODE Commands by Function ] [ Alphabetical List of R-CODE Commands ] [ Command Reference ] [ R-CODE Operator Quick Reference ] [ List of R-CODE System Variables ] [Variables] [Voice ID List] [AiboSound ID List] [AiboTone ID List] [How to start R-CODE] [WirelessLAN communication] [LED, MIDI Table] [ Changes ] 2005.2.16 * R-CODE numeric processing bug (compare and four basic arithmetic operations) has been fixed. 32bit intergers are now treated correctly. * RRLeg (right rear) sensor data can be read correctly. [ R-CODE Coding Conventions ] 1) A line may be up to 127 bytes long (total, including comments and a newline character). 2) R-CODE commands consist of words separated by colons (:). Word1:Word2:Word3 3) Only alphanumeric Ascii characters and underscores (_) may be used in words. NOTE: other symbols have special meanings. 4) Space and Tab characters at the heads of lines are ignored (for indenting) 5) Lines beginning with a colon (:) are considered to be label rows. :Label 6) Lines whose first character is not an alphanumeric Ascii character or colon (:) are treated as comment lines, and ignored. 7) If a double slash (//) is contained in a line, everything thereafter in that line is treated as a comment, and ignored. Word1:Word2:Word3 // comment 8) Since colons (:), spaces, tabs, and newline characters are treated as separators, they cannot be used in names and the like. In order to include these characters in format strings and the like, wrap the entire string in double quotes (""). PRINT:"x = %d":x 9) Words starting with the following characters are treated as numbers: + - 0 1 2 3 4 5 6 7 8 9 Numbers whose first two characters are 0x or 0X are treated as hexadecimal numbers. Numbers whose first two characters are 0o or 0O are treated as octal numbers. Numbers whose first two characters are 0b or 0B are treated as binary numbers. SET:x:0x03FC SET:y:0o0777 SET:z:0b00001111 10) Words in ALL-CAPS are reserved for R-CODE system use. Please do not use ALL-CAPS for user variable names, etc. BAD -- SET:USER1:0 (could cause future conflicts with words reserved by the R-CODE system) GOOD -- SET:user1:0 (use of all lowercase variable names recommended) CAUTION -- SET:User1:0 (make sure capitalized names do not overlap with system variables) [ List of R-CODE Commands by Function ] Control EDIT Load program END Program load termination RUN Begin execution EXIT Terminate execution HALT Terminate and shutdown INIT Initialize ! Break (force stop) Actions PLAY Play action STOP Normal stop QUIT Emergency stop WAIT Wait SYNC Synchronize NONE No operation Printing PRINT Print Control Structures : Label GO Jump IF Conditional test SWITCH Multiway-branching (Context value setting) CSET Multiway-branching (Context value setting) CASE Multiway-branching (Conditional execution) FOR FOR loop NEXT FOR loop termination WHILE WHILE loop WEND WHILE loop termination REPEAT REPEAT loop UNTIL REPEAT loop termination DO DO loop LOOP DO loop termination BREAK Break out of loop CALL Call subroutine ARG Retrieve subroutine argument RETURN Return from subroutine RET Return from subroutine (context version) ONCALL Register interrupt routine RESUME Return from interrupt routine Variables GLOBAL Global variable declaration LOCAL Local variable declaration LET Assign (simple assignment) SET Assign (with special functions) GET Refer (for debugging) CLR Clear sensor variable VSAVE Save variable value VLOAD Load variable value VDUMP Display variable value Operators ADD Add SUB Subtract MUL Multiply DIV Divide MOD Remainder AND Logical product IOR Inclusive OR XOR Exclusive OR NOT Negation LAND Logical product (Boolean operator) LIOR Inclusive OR (Boolean operator) LNOT Negation (Boolean operator) EQ Equal NE Not equal to LT Less than LE Less than or equal to GT Greater than GE Greater than or equal to RND Random number Stack Operations PUSH Add element to stack POP Remove element from stack DUP Copy stack top JT Jump if stack top is true JF Jump if stack top is false [ Alphabetical List of R-CODE Commands ] ! Break (force stop) : Label ADD Add AND Logical product ARG Retrieve subroutine argument BREAK Break out of loop CALL Call subroutine CASE Multiway-branching (Conditional execution) CLR Clear sensor variable CSET Multiway-branching (Context value setting) DIV Divide DO DO loop DUP Copy stack top EDIT Load program END Program load end point EQ Equal EXIT Terminate execution FOR FOR loop GE Greater than or equal to GET Refer (for debugging) GLOBAL Global variable declaration GO Jump GT Greater than HALT Terminate and shutdown IF Conditional test INIT Initialize IOR Logical sum JF Jump if stack top is false JT Jump if stack top is true LAND Logical product (Boolean operator) LE Less than or equal to LET Assign (simple assignment) LIOR Inclusive OR (Boolean operator) LNOT Negation (Boolean operator) LOCAL Local variable declaration LOOP DO loop termination LT Less than MOD Remainder MUL Multiply NE Not equal to NEXT FOR loop end point NONE No operation NOT Negation ONCALL Register interrupt routine PLAY Play action POP Remove element from stack PRINT Print PUSH Add element to stack QUIT Emergency stop REPEAT REPEAT loop RESUME Return from interrupt routine RET Return from subroutine (context version) RETURN Return from subroutine RND Random number RUN Begin execution SET Assign (with special functions) STOP Normal stop SUB Subtract SWITCH Multiway-branching (Context value setting) SYNC Synchronize UNTIL REPEAT loop termination VDUMP Display variable value VLOAD Load variable value VSAVE Save variable value WAIT Wait WEND WHILE loop end point WHILE WHILE loop XOR Exclusive OR --------------------------------------------------------------------------- Name EDIT - Load program (Transfer program from PC to AIBO) Format EDIT < program > END Arguments None Description Loads R-CODE program from EDIT to END into memory. Any program already existing in memory is deleted. Example EDIT FOR:i:1:10 PLAY:ACTION:xxx WAIT NEXT EXIT END --------------------------------------------------------------------------- Name END - Program load termination Format EDIT < program > END Arguments None Description See description for EDIT. Example EDIT FOR:i:1:10 PLAY:ACTION:xxx WAIT NEXT EXIT END --------------------------------------------------------------------------- Name RUN - Execute program Format RUN Arguments None Description Begins execution of program currently in memory. Example RUN --------------------------------------------------------------------------- Name EXIT - Terminate program Format EXIT Arguments None Description Halts program execution. Example EDIT FOR:i:1:10 PLAY:ACTION:xxx WAIT NEXT EXIT END --------------------------------------------------------------------------- Name HALT - Halt program / shut down AIBO Format HALT Arguments None Description Halt currently running program, and shut down AIBO. Shutdown takes several seconds. Example EDIT FOR:i:1:10 PLAY:ACTION:xxx WAIT NEXT HALT END --------------------------------------------------------------------------- Name INIT - initialize R-CODE Format INIT: Arguments See description Description INIT:0 Initialize whole R-CODE system. This is performed automatically at startup. This is for system use only. Do not use this command in your R-code. INIT:1 Enter debug mode. For R-CODE Debugger (currently being developed separately) Do not use this command in your R-code. INIT:2 Initialize dictionary and variable table to startup values. INIT:3 Initialize at the time of WLAN connection. This is performed automatically upon WLAN connection. Optional second argument specifies the machine ID (AiboId). Do not use this command in your R-code. INIT:4 WLAN Disconnect notification (Rcomm->RMain) INIT:9 Shutdown & Reboot Example INIT (same as INIT:0) INIT:2 --------------------------------------------------------------------------- Name ! Break (force stop) Format ! Conduct emergency stop, and halt program execution. !! Conduct normal stop, and halt program execution. !!! Conduct emergency stop, halt program execution, and initialize environment. Arguments None Description Forces program execution to halt. For control from AMS and other PC applications. Example ! --------------------------------------------------------------------------- Name PLAY -- Play action Format General format PLAY:ACTION:[:::] PLAY:MWCID:[:::] Arguments -- Action name -- Optional arguments (vary depending on Action) Constant value or Variable name MWCommandID Description Plays action specified by . The action names that can be specified by are defined in ACTION.AMS(/OPEN-R/APP/PC/AMS/ACTION.AMS). Plays MWCommand specified by MWCommand can be called if the is known. A check is made of the current posture and the starting posture of the action to be played. If they are not the same posture, AIBO automatically transitions to the starting posture. The or will be played once AIBO is in the starting posture. Argument Pattern : // WALK, KICK, TOUCH, etc. // TURN, etc. : // MOVE_HEAD, etc. // SEARCH, etc. Angle unit is degrees Distance unit is millimeters Currently, only PINK_BALL can be specified as . Example PLAY:ACTION:STAND --------------------------------------------------------------------------- Name STOP - Normal stop Format STOP Arguments None Description Normal stop of action. Discards all actions remaining in the queue. If an action is currently being played, stops after that action is completed. Example STOP --------------------------------------------------------------------------- Name QUIT -- Emergency stop Format QUIT Arguments None Description Emergency stop of action. Discards all actions remaining in the queue. Immediately halts operation, including any action currently being performed. Note: If QUIT is used, the posture is reset to an undefined state. Example QUIT --------------------------------------------------------------------------- Name WAIT - Wait until end of action (synchronize) Format WAIT Wait until the end of the preceding action. WAIT: Wait specified amount of time. Arguments milliseconds [1 - 30000] Note: resolution is 32 ms Description Waits until the end of the preceding action that is being executed. Temporarily halts program execution. WAIT has no effect in a state where there is nothing to wait for. If is specified, processing is suspended for the specified amount of time. Example WAIT WAIT:1000 --------------------------------------------------------------------------- Name SYNC - External synchronization Format SYNC Arguments None Description Executing SYNC during program execution pauses the program, and goes into standby for input. Processing restarts when the "SYNC" command string is sent. Example SYNC --------------------------------------------------------------------------- Name NONE No operation Format NONE Arguments None Description A "no-operation" statement. Processing immediately continues on the next line. Example NONE --------------------------------------------------------------------------- Name PRINT - Print (for online debugging) Format PRINT:[:::::] Arguments Format string %d Decimal notation %x Hexadecimal notation - Variable name. Description Display messages using method similar to the C printf() command. If includes spaces or tabs, enclose the entire string in double quotes (""). Example PRINT:"x=%d y=%d":x:y --------------------------------------------------------------------------- Name :