Second Life Bots and Motion Planning

Document Sample
scope of work template
							                  MOTION PLANNING IN REAL AND VIRTUAL ENVIRONMENTS
                                                           FALL 2007




                 Second Life:
                     Bots and
              Motion Planning
                                    Russell Gayle
            Comp 790-058 – Robot Motion Planning
                                       Fall 2007

                                      October 1, 2007




5/23/2010                                                      1
                                           Last time
RECAP                • SL Overview
INTRO: SL BOTS
                           »    The Grid
LSL BOTS
1. Framework               »    Simulators / Regions
2. Planning
                           »    Avatars, Primitives
3. Results
4. Other MP Ideas          »    LSL Crash Course
LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                    5/23/2010                          2
                                  Aside: Path Tracer
RECAP                • Results of the LSL portion (Part 0) should
INTRO: SL BOTS
                       look something like this:
LSL BOTS
1. Framework
                           » http://www.youtube.com/watch?v=bcemyUuzC
2. Planning                  ds&eurl=
3. Results
4. Other MP Ideas

LIBSECONDLIFE        • Update:
1. Framework
2. Avatar Control
                           » As of this morning, the UNC Sandbox has
3. Planning                  turned into an access restricted area.
4. Demo
5. Other Ideas
                           » I’ve emailed UNC about a place where I can
                             put it.
                           » If I don’t hear back soon, I’ll send it out to
                             everyone.


                    5/23/2010                                                 3
                                Introduction: SL Bots
RECAP                • What are bots?
INTRO: SL BOTS
                           » In Second Life?
LSL BOTS
1. Framework         • Two varieties
2. Planning
3. Results
                           » LSL based (prims)
4. Other MP Ideas               • Come in many shapes and sizes
LIBSECONDLIFE                   • Wide range of functions
1. Framework
2. Avatar Control
                                • Primarily server side code
3. Planning                » LibSL based (avatars)
4. Demo
5. Other Ideas                  • Function by manipulating avatars
                                • Mixed computation from client and server
                                    » Network delay becomes an issue



                    5/23/2010                                                4
                                           LSL Bots
RECAP                • Prims with (motion) control
INTRO: SL BOTS
                           » Control is defined through LSL
LSL BOTS
1. Framework               » Integrated sensing (LSL sensors)
2. Planning
                           » Can interface with remote resources
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
                     • http://www.youtube.com/watch?v=824TFPer
2. Avatar Control      XsQ
3. Planning
4. Demo
5. Other Ideas
                     • Some of the remaining content for this
                       section is adapted from:
                           » Alon Shalita
                           » Tel-Aviv University
                           » Motion Planning in Virtual Environments Workshop
                    5/23/2010                                                   5
                           LSL Bots: LSL Limitations
RECAP                • List limitations
INTRO: SL BOTS
                           » No native arrays
LSL BOTS
1. Framework
                                • Lists are sequential access
2. Planning                » Limited length
3. Results
                                • Limited by memory script has available (16KB total)
4. Other MP Ideas

LIBSECONDLIFE
                                • Compile time lists are limited to 72
1. Framework               » No nested lists
2. Avatar Control
3. Planning          • Type conversion
4. Demo
                           » More of an annoyance, automatic conversion
5. Other Ideas
                             may not work
                     • Cannot incorporate existing libraries
                     • SL is moving to Mono (Open Source C#)
                           » Not sure when this will happen though
                    5/23/2010                                                           6
                                LSL Bots: Framework
RECAP                • Limitations make it difficult to develop large,
INTRO: SL BOTS
                       complex applications (like motion planning)
LSL BOTS
1. Framework
                           » Track open issues at:
2. Planning                     • https://jira.secondlife.com/browse/SVC/compon
3. Results
                                  ent/10043
4. Other MP Ideas

LIBSECONDLIFE              » Though, predefined motion like the roomba
1. Framework                 example should not be too hard
2. Avatar Control
3. Planning          • One solution: Use remote resources
4. Demo
                           » Hybrid planner
5. Other Ideas
                                • Motion, physics, controls stay in SL
                                • Communicate with remote resources to get
                                  planning solutions



                    5/23/2010                                                 7
                          LSL Bots: Communications
RECAP                • LSL has the ability to send and receive
INTRO: SL BOTS
                       communications
LSL BOTS
1. Framework
                           » XML-RPC (inbound)
2. Planning
                           » HTTP (outbound)
3. Results
4. Other MP Ideas    • XML-RPC
LIBSECONDLIFE
                           » Data limited to about 255 bytes
1. Framework
2. Avatar Control          » Long latency (about 3 seconds)
                     • HTTP
3. Planning
4. Demo
5. Other Ideas
                           »    Data in request limited to script’s free memory
                           »    Data in response limited to 2049 bytes
                           »    Responses is asynchronous
                           »    Do not send more than 1 per second

                    5/23/2010                                                     8
                           LSL Bots: Comm. Example
RECAP                • HTTP makes the most sense
INTRO: SL BOTS
                     • Example:
LSL BOTS
                                                               Uses HTTP POST request
1. Framework               » PHP Number Adder
2. Planning
                                <?php
3. Results                      $first=$_POST["first"];
4. Other MP Ideas               $second=$_POST["second"];

LIBSECONDLIFE                   if (!ereg("[0-9]+", $first) or !ereg("[0-9]+", $second))
1. Framework                    {
                                  die ("first and second must be numbers");
2. Avatar Control               }
3. Planning
                                echo $first+$second;
4. Demo
                                ?>
5. Other Ideas




                           » HTTP POST allows more data to be sent
                           » HTTP GET is limited to call length

                    5/23/2010                                                              9
                             LSL Bots: Comm. Example
RECAP                • HTTP makes the most sense
INTRO: SL BOTS
                     • Example:
LSL BOTS
1. Framework                 » Number Adder LSL Script
2. Planning          key requestid;

3. Results           default
                     {
4. Other MP Ideas        state_entry()
                         {
LIBSECONDLIFE                llSay(0, "Hello, Avatar!");             Initiate HTTP request
                         }
1. Framework
                         touch_start(integer total_number)
                                                                           Process response
2. Avatar Control        {
3. Planning                  llSay(0, "Touched.");

4. Demo                      requestid = llHTTPRequest("http://www.somehostname.com/add.php",
                             [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
5. Other Ideas               "first=9&second=20");
                         }

                         http_response(key request_id, integer status, list metadata, string body)
                         {
                             if (request_id == requestid)
                             {
                                 llSay(0, body);
                             } else
                                 llSay(0,(string)status+" error");
                         }
                     }


                    5/23/2010                                                                             10
                                   LSL Bots: Sensors
RECAP                • Functionality for scripts to scan for items
INTRO: SL BOTS
                           » Scan by name/id, type
LSL BOTS
1. Framework               » Within a range and arc radians from viewing
2. Planning                  direction
3. Results
                                llSensor( string name, key id, integer
4. Other MP Ideas
                                  type, float range, float arc );
LIBSECONDLIFE
1. Framework               » llSensor
2. Avatar Control
                                • Run a sensor once
3. Planning
4. Demo                    » llSensorRepeat
5. Other Ideas
                                • Repeat the same sensor over some interval
                           » llSensorRemove
                                • Remove a repeating sensor



                    5/23/2010                                                 11
                             LSL Bots: Sensor example
RECAP                • Finding the start of a maze (Alon Shalita)
INTRO: SL BOTS
LSL BOTS                 default
1. Framework             {

2. Planning
                             state_entry()                              Find maze start
                             {
                                 llSay(0, "Touch me to scan for the maze");
3. Results                   }
4. Other MP Ideas                                                             Start sensor
                                touch_start(integer total_number)               With any id
LIBSECONDLIFE                   {
                                    llSay(0, "Touched.");
1. Framework                        llSensor("Maze Start", NULL_KEY, ACTIVE | PASSIVE, 90, PI);
                                }
2. Avatar Control
3. Planning                     sensor(integer total_number)
                                {
4. Demo                             if (llDetectedName(0) == "Maze Start")  Either moving or not
                                    {
5. Other Ideas                          llSay(0, "Maze start is at " + (string)llDetectedPos(0));
                                    }
                                }
                                             Within 90 meters                   Within a sphere
                                no_sensor()
                                {
                                                                                around the rim
                                    llSay(0, "Error: Sensor failed");
                                }
                         }



                    5/23/2010                                                                       12
                             LSL Bots: Sensor example
RECAP                • Finding the start of a maze (Alon Shalita)
INTRO: SL BOTS
LSL BOTS                 default
1. Framework             {
                             state_entry()
2. Planning                  {
                                 llSay(0, "Touch me to scan for the maze");
3. Results                   }
4. Other MP Ideas
                                touch_start(integer total_number)       Sensor returned an item
LIBSECONDLIFE                   {
                                    llSay(0, "Touched.");
1. Framework                        llSensor("Maze Start", NULL_KEY, ACTIVE | PASSIVE, 90, PI);
                                }
2. Avatar Control
3. Planning                     sensor(integer total_number)
                                {
4. Demo                             if (llDetectedName(0) == "Maze Start")       Nothing returned
                                    {
5. Other Ideas                          llSay(0, "Maze start is at " + (string)llDetectedPos(0));
                                    }
                                }

                                no_sensor()
                                {
                                    llSay(0, "Error: Sensor failed");
                                }
                         }



                    5/23/2010                                                                       13
                           LSL Bots: Motion Planning
RECAP                • There are several possible solutions
INTRO: SL BOTS
                           » Using CGAL
LSL BOTS
1. Framework
                                • Proposed by Danny Halperin and Alon Shalita
2. Planning
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                                                                     Stop
                                Start


                    5/23/2010                   Obstacles                       14
                           LSL Bots: Motion Planning
RECAP                • There are several possible solutions
INTRO: SL BOTS
                           » Using CGAL
LSL BOTS
1. Framework
                                • Proposed by Danny Halperin and Alon Shalita
2. Planning                     1. Write a script to “sense” obstacles
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                                                                         Stop
                                Start


                    5/23/2010                        Obstacles                  15
                           LSL Bots: Motion Planning
RECAP                • There are several possible solutions
INTRO: SL BOTS
                           » Using CGAL
LSL BOTS
1. Framework
                                • Proposed by Danny Halperin and Alon Shalita
2. Planning                     1. Write a script to “sense” obstacles
3. Results
                                2. Append robot and obstacles to a file
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                                                                          Stop
                                Start


                    5/23/2010                       Obstacles                    16
                           LSL Bots: Motion Planning
RECAP                • There are several possible solutions
INTRO: SL BOTS
                           » Using CGAL
LSL BOTS
1. Framework
                                • Proposed by Danny Halperin and Alon Shalita
2. Planning                     1. Write a script to “sense” obstacles
3. Results
                                2. Append robot and obstacles to a file
4. Other MP Ideas
                                3. Run CGAL on the file and send the response
LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                                                                          Stop
                                Start


                    5/23/2010                      Obstacles                     17
                           LSL Bots: Motion Planning
RECAP                • There are several possible solutions
INTRO: SL BOTS
                           » Using CGAL
LSL BOTS
1. Framework
                                • Proposed by Danny Halperin and Alon Shalita
2. Planning                     1. Write a script to “sense” obstacles
3. Results
                                2. Append robot and obstacles to a file
4. Other MP Ideas
                                3. Run CGAL on the file and send the response
LIBSECONDLIFE
1. Framework
                                4. Process the response and run the path
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                                                                          Stop
                                Start


                    5/23/2010                      Obstacles                     18
                            LSL Bots: Considerations
RECAP                •     Identifying obstacles
INTRO: SL BOTS
                           »    Sensors only return nearest 16 objects
LSL BOTS
1. Framework
                                •   This may be fixed soon
2. Planning
                           »    Much easier for self-built environments
3. Results
4. Other MP Ideas               •   Know exactly which prims to look for
LIBSECONDLIFE        •     Limited script memory, HTTP response size
1. Framework
2. Avatar Control          »    Can only send finite amounts at a time
3. Planning
                                •   Send in groups
4. Demo
5. Other Ideas             »    Process results in groups
                     •     Note: CGAL is not necessary
                           »    Any command-line planner which can return
                                text information to SL should suffice

                    5/23/2010                                              19
                            LSL Bots: Results Movies
RECAP
INTRO: SL BOTS
LSL BOTS
1. Framework
2. Planning
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                    5/23/2010                          20
                         LSL Bots: Some other ideas
RECAP                • None of these have been implemented (to my
INTRO: SL BOTS
                       knowledge)
LSL BOTS
1. Framework
                           » Bug algorithm
2. Planning
                           » Online mapping
3. Results
4. Other MP Ideas               • Have the robot move until it collides, record this
LIBSECONDLIFE                     information
1. Framework               » Use other prims as waypoints
2. Avatar Control
3. Planning                     • Difficult to maintain
4. Demo                         • Ordering could be maintained and stored
5. Other Ideas
                                  remotely
                           » Potential fields
                                • Keep track of a goal and move in that direction
                                  while moving away from obstacles

                    5/23/2010                                                     21
                                LibSecondLife (LibSL)
RECAP                • Potential for complete avatar simulation
INTRO: SL BOTS
                           » Reverse engineering of SL network protocol
LSL BOTS
1. Framework               » Framework for using protocol with The Grid
2. Planning
                           » Theoretically, could implement new SL viewer
3. Results
4. Other MP Ideas    • Based on C#
LIBSECONDLIFE
1. Framework
                           » All C# features are available
2. Avatar Control          » Much more flexible programming environment
3. Planning
4. Demo              • Avatar control
5. Other Ideas
                           » Could have an avatar control a prim, in theory
                     • Client-server interface
                     • Extend range of SL capabilities
                     • Actively developed
                           » Much of this section is just ideas so far
                    5/23/2010                                             22
                                LibSL: Getting Started
RECAP                • Prerequisites
INTRO: SL BOTS
                           » C# compiler
LSL BOTS
1. Framework
                                • Mono (all platforms except Windows)
2. Planning                     • Visual Studio .NET 2005 (Windows)
3. Results
4. Other MP Ideas
                                • Visual Studio Express .NET (Windows, free)
LIBSECONDLIFE              » Source code via SubVersion
1. Framework
                                • svn://openmetaverse.org/libsl/trunk
2. Avatar Control
3. Planning                1. Build code
4. Demo
5. Other Ideas
                           2. Start a new project
                           3. Add libsecondlife as a reference
                           » For more help:
                                • http://www.libsecondlife.org/wiki/Use_libSL_to_l
                                  ogin_to_the_SL_grid

                    5/23/2010                                                   23
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                           Include libsecondlife libraries
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     24
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                            Define SecondLife client(s)
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     25
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                                Add your bot’s name
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     26
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                             Define a connected event
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     27
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                               Try to log in to the Grid
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     28
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                     When connected, send a message
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     29
                                        LibSL: Framework
                     • LibSL example
RECAP                using   System;
                     using   System.Collections.Generic;
INTRO: SL BOTS       using   System.Text;
                     using   libsecondlife;                          After your message, logout
LSL BOTS
                     namespace MyFirstBot {
1. Framework              class MyFirstBot {
                                 public static SecondLife client = new SecondLife();
2. Planning                      private static string first_name = "First";
3. Results                       private static string last_name = "Last";
                                 private static string password = "password";
4. Other MP Ideas
                                   public static void Main() {
LIBSECONDLIFE                                  client.Network.OnConnected += new
1. Framework                       NetworkManager.ConnectedCallback(Network_OnConnected);
2. Avatar Control                              if (client.Network.Login(first_name, last_name, password,
                                               "My First Bot", "Your name")) {
3. Planning                                                Console.WriteLine("I logged into Second Life!");
                                               } else {
4. Demo                                                    Console.WriteLine("I couldn't log in, here is why: "
5. Other Ideas                                             + client.Network.LoginMessage);
                                               }
                                   }

                                   static void Network_OnConnected(object sender) {
                                               Console.WriteLine("I'm connected to the simulator, going to
                                                                        greet everyone around me");
                                               client.Self.Chat("Hello World!", 0, ChatType.Normal);
                                                                        Console.WriteLine("Now I am going to
                                                                        logout of SL.. Goodbye!");
                                               client.Network.Logout();
                                   }
                             }
                    5/23/2010
                     }                                                                                     30
                                   LibSL: Framework
RECAP                • Most actions are defined within callbacks
INTRO: SL BOTS
                       (events)
LSL BOTS
1. Framework
                           » Network events
2. Planning                     • OnConnected / OnDisconnected
3. Results
4. Other MP Ideas
                                • OnCurrentSimChanged
LIBSECONDLIFE              » Client (Avatar) events
1. Framework
                                • OnInstantMessage
2. Avatar Control
3. Planning                     • OnChat
4. Demo
                                • OnTeleport
5. Other Ideas
                           » Object events
                                • OnNewAvatar / OnNewPrim
                                • OnObjectUpdated / OnObjectKilled


                    5/23/2010                                        31
                                   LibSL: TestClient
RECAP                • Application provided with the SVN code base
INTRO: SL BOTS
                           » Open source
LSL BOTS
1. Framework               » Standard LibSL development framework
2. Planning
3. Results
                     • Most actions are included as commands
4. Other MP Ideas          » Easy to define and use
LIBSECONDLIFE
1. Framework
                           » Invoked from console or by assigning a
2. Avatar Control            “Master” for your bot
3. Planning
                           » e.g. Wear, GiveAll, Stats, Location, Sit
4. Demo
5. Other Ideas       • Supports multiple simultaneous avatar bots
                     • Organizes most incoming objects as the SL
                       viewer would see them


                    5/23/2010                                           32
                                LibSL: Avatar Control
RECAP                • For planning, we must be able to move the
INTRO: SL BOTS
                       avatar to a desired location
LSL BOTS
1. Framework
                           » No built in command for avatars
2. Planning                     • You may be able to hack something by
3. Results
                                  attaching a prim that can move
4. Other MP Ideas

LIBSECONDLIFE        • Use LibSL to build a simple motion controller
1. Framework
                           » LibSL can send data packets which instruct
2. Avatar Control
3. Planning                  the avatar to move
4. Demo
5. Other Ideas
                     • For SL planning purposes (thus far), the
                       following should suffice
                           » Move to a position specified by a distance and
                             direction
                           » Move to a specified position
                    5/23/2010                                             33
                                LibSL: Avatar Control
RECAP                • Homework 1 Hints
INTRO: SL BOTS
                           » If you use TestClient, make use of existing
LSL BOTS
1. Framework
                             commands
2. Planning                » It will be very valuable to allow your robot to
3. Results
4. Other MP Ideas
                             move toward either
LIBSECONDLIFE                   • A sequence of points
1. Framework                    • A sequence of direction/distance pairs
2. Avatar Control
3. Planning                » Make yourself a meter marker to test accuracy
4. Demo
5. Other Ideas




                    5/23/2010                                                  34
                                LibSL: Motion Planning
RECAP                • Given a basic controller, we need to tell the
INTRO: SL BOTS
                       avatar where to go
LSL BOTS
1. Framework         • Several standard approaches
2. Planning
                           » Cell Decomposition
3. Results
4. Other MP Ideas          » Potential Fields
LIBSECONDLIFE
                           » Roadmap
1. Framework
2. Avatar Control    • For all approaches, “sensing” the
3. Planning
4. Demo
                       environment is necessary
5. Other Ideas             » LibSL comes with an ObjectManager class
                           » Keeps a Dictionary of all current Prims and
                             Avatars
                                • In the same way the SL viewer does, as far as
                                  they understand
                    5/23/2010                                                     35
                            LibSL: Local Mapping and
                                    Planning
RECAP                • Bug-like approach to planning
INTRO: SL BOTS
                           1. Move your avatar in a direction toward the
LSL BOTS
1. Framework
                              goal as far as possible
2. Planning                2. Have it follow the barrier in a given direction
3. Results
4. Other MP Ideas
                              until you can make progress toward the goal
LIBSECONDLIFE
                              again
1. Framework
                     •     No need memorize the environment, just
2. Avatar Control
3. Planning                when you’re colliding
4. Demo
5. Other Ideas




                    5/23/2010                                               36
                                LibSL: Local Reactions
RECAP                • Standard walking motion in SL signaled
INTRO: SL BOTS
                       through “AutoPilot” packets
LSL BOTS
1. Framework
                           » This is essentially the straight-line path
2. Planning
                           » It is cancelled when an event occurs that
3. Results
4. Other MP Ideas
                             causes the motion to end
LIBSECONDLIFE                   • Collision
1. Framework                    • Reached destination
2. Avatar Control
3. Planning          • Thus, avatars cannot easily react
4. Demo
5. Other Ideas
                           » Need a motion model that is modifiable
                     • A solution
                           » Move in small increments
                           » Requires some careful tuning of current
                             velocity to keep motion smooth
                    5/23/2010                                             37
                                LibSL: Behavior Control
RECAP                • Avatars come with default behavior
INTRO: SL BOTS
                           » However, they are capable of performing other
LSL BOTS
1. Framework
                             actions / animations
2. Planning
                     • Solution: Animation Override (AO) to the
3. Results
4. Other MP Ideas      rescue
LIBSECONDLIFE              » Collect a set of animations you’d like to use
1. Framework
2. Avatar Control
                           » Get an AO gadget
3. Planning                     • Francis Chung's Wet Ikon seems to be a free
4. Demo
                                  favorite
5. Other Ideas
                           » When embedded in a worn prim, it will
                             override the default
                           » Depending on the environment, use LibSL to
                             change the various animations
                           » Video?
                    5/23/2010                                                   38
                                  LibSL: Demo
RECAP                • Basics of LibSL and TestClient
INTRO: SL BOTS
LSL BOTS
1. Framework
2. Planning
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control
3. Planning
4. Demo
5. Other Ideas




                    5/23/2010                           39
                                   LibSL: Other Ideas
RECAP                • A more kinodynamic approach
INTRO: SL BOTS
                           » Alter the motion controller to be like that of a
LSL BOTS
1. Framework
                             car
2. Planning
                     • Hybrid approach
3. Results
4. Other MP Ideas          » What I’m currently playing with
LIBSECONDLIFE              » Prims do a great job of finding nearby
1. Framework
2. Avatar Control
                             obstacles
3. Planning                » Prims are easy to move
4. Demo
5. Other Ideas             » Use a sequence of prims as a roadmap
                                • Easy for an avatar to follow
                                • Difficult to maintain



                    5/23/2010                                                   40
                                             Fin
RECAP                • Motion Planning in SL
INTRO: SL BOTS
                           » Using LSL
LSL BOTS
1. Framework               » Using LibSL
2. Planning
3. Results
4. Other MP Ideas

LIBSECONDLIFE
1. Framework
2. Avatar Control                          Any questions?
3. Planning
4. Demo
5. Other Ideas




                    5/23/2010                               41

						
Related docs