Andrew Coates ::: MSFT

It's all about community!

  • Andrew Coates ::: MSFT

    The Platform Story–now available as an animated Feature

    • 2 Comments

    Some time ago now, I posted a thought piece in which I explained the evolution of the platform using the analogy of the evolution of water supply. At a recent internal event, I presented this analogy to help explain how cloud computing changes the way we think about the supply of computing services and infrastructure.

    Get Microsoft Silverlight

    I've uploaded the video to Channel9, so you can go there to watch it streamed or to download in various formats including Zune, MP3, MP4, WMA and WMV.

    Let me know what you think.

  • Andrew Coates ::: MSFT

    Guidance for developing applications for SharePoint 2010

    • 0 Comments

    I got this in my inbox this morning:

    Patterns and Practices Logo

    Microsoft patterns & practices is excited to announce the release of:

    Developing Applications for SharePoint 2010

    On MSDN: http://www.microsoft.com/spg
    On CodePlex: http://spg.codeplex.com/

  • Andrew Coates ::: MSFT

    Training Kit Redux–More developer resources than you could shake a stick at

    • 0 Comments

    A while ago, I did a post about the great Developer Training Kits available for free download from Microsoft. Since then, we've released a bunch more, so I thought I'd list all of the ones I use regularly in one place. Each of these great resources include hundreds of MB videos, presentations, white papers, demo scripts, labs and more. Grab them today.

    Search for "Training Kit" on the Microsoft Download Centre

  • Andrew Coates ::: MSFT

    Document Creation and Conversion with the OpenXML SDK and SharePoint 2010 Word Automation Services – Part 1

    • 0 Comments

    Update 2011-04-06 I Finally got around to writing Part 2 of this post.

    I had the pleasure this week of presenting at the Australian SharePoint Conference – much kudos to NZ SharePoint MVPs Debbie Ireland and Mark Orange, and local SharePoint MVPs/community folk James Milne, Brendan Law and Kathy Hughes and the team for putting on such a great event.

    My session was entitled "Creating and manipulating documents with Word Services and Open XML" and covered the use of the OpenXML SDK and a new feature in SharePoint 2010 (Standard and above) called Word Automation Services. I've uploaded the deck to my SkyDrive, and you can grab it from there.

    Disclaimer

    I stole a bunch of the code I showed (or at least the concepts for it) from Eric White's excellent blog, several posts from the Word Team and from MSDN:

    Development Environment

    I ran these demos on a HP Envy 15 with 8 GB of RAM, a Core i7 processor running Windows 7 x64 and with both SharePoint 2010 and Visual Studio 2010 installed.

    See the MSDN Article "Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008"for information on how to set up your development environment for SharePoint development and then read Beth Massi's notes on that article to actually get it working – "Setting up Windows 7 for Office & SharePoint 2010 Beta Development".

    I installed the OpenXML SDK 2.0 – download from here, documentation here.

    I also installed the Visual Studio 2010 Pro Power Tools. If you don't have this wonderful set of tools installed on your machine stop reading this now and go and install them. I mean it. Right now!

    Demo Code

    Set up a Windows Form to call your code from

    I built a Winforms app to demonstrate the document creation concepts and if you want to follow along, you can do the same. You know the drill, File|New Project, or just New Project from the VS2010 Start Page

    Create a new WinForms Project

    Notice I've used a C# project for this. A later step, reflecting the template document, results in C# code that you'll put into a class in this project so that's why I used C#. I guess you could put the reflected code into a separate class library project and do the rest in VB.NET if you like. I'll leave that as a exercise for the reader.

    Drop 4 Buttons and a NumericUpDown on the form and set some properties as follows

    ControlNameText
    button1 CreateOneDocumentLocallyButton Create One Document Locally
    button2 CreateManyDocumentsLocallyButton Create Many Documents Locally
    button3 CreateOneSharePointDocumentButton Create One Document on SharePoint
    button4 CreateManySharePointDocumentsButton Create Many Documents on SharePoint

    and

    ControlNameIncrementMaximumMinimumValue
    numericUpDown1 NumberOfDocuments 100 1000 0 100

    You should have a form that looks a bit like this:

    Form layout

    Generate a Document using the OpenXML SDK

    Now it's time to actually generate the document using the OpenXML SDK.

    The first thing to do is separate your generation code from your UI, so double-click on the CreateOneDocumentLocallyButton button to generate a click event handler and then in the event.

    In the Form1 class definition, before the constructor, instantiate a new DocGenerator class (don't worry that you haven't created a class definition yet, you will in a sec):

    DocGenerator gen = new DocGenerator();

    In the button click event, call the DocGenerator's CreateOneDocumentLocally method and then show a MessageBox to confirm that something's happened. Your form code should look like this:

    1. using System;
    2. using System.Collections.Generic;
    3. using System.ComponentModel;
    4. using System.Data;
    5. using System.Drawing;
    6. using System.Linq;
    7. using System.Text;
    8. using System.Windows.Forms;
    9.  
    10. namespace OpenXMLDocumentGeneration
    11. {
    12.     public partial class Form1 : Form
    13.     {
    14.         DocGenerator gen = new DocGenerator();
    15.  
    16.         public Form1()
    17.         {
    18.             InitializeComponent();
    19.         }
    20.  
    21.         private void CreateOneDocumentLocallyButton_Click(object sender, EventArgs e)
    22.         {
    23.             gen.CreateOneDocumentLocally();
    24.             MessageBox.Show("Done");
    25.         }
    26.     }
    27. }

    Now it's time for the Visual Studio Magic™. Position your cursor somewhere on the word DocGenerator (in Line 14 above) and press Ctrl+. (that's hold the Control key down and press the full stop, or period button). A Smart Tag will pop up offering to either generate a new class for Doc Generator or a new type.

    Generate new class or type smart tag

    If you choose Generate New Type, you'll get a dialog offering to generate one of four different types, with a number of access  options and decisions to be made about where the type definition should be stored:

    The Generate New Type dialog gives you lots of options

    If you choose the default Generate class option though, Visual Studio will generate a new class file with the same name as the class being defined (in this case, DocGenerator) and a class definition for that class in the default namespace.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace OpenXMLDocumentGeneration
    {
        class DocGenerator
        {
        }
    }

    This is a great time-saving feature that allows you to work from the inside-out with your creation of types.

    The same technique works for defining the methods on the class. Putting  the cursor somewhere in the gen.CreateOneDocumentLocally() text (in line 23 above) and pressing Ctrl+. will prompt you to create a method stub for the method you've yet to define.

    Generate a method stub for the hereto undefined method.

    Now you need to add the code that will generate the document.

    The first thing to do is add a couple of references to the project. Right-click on your project in the Solution Explorer and choose Add Reference. If you've done what I told you you should above and installed the Visual Studio 2010 Pro Power Tools, you'll get a dialog that looks like this (note that assemblies that are already referenced in the project have a green "check mark" icon next to them):

    The new Add Reference dialog

    Remember that the OpenXML SDK is a set of wrappers around the System.IO.Packaging namespace, which is in the Windowsbase assembly, so you need to add references to something with OpenXML in the name, and to Windowsbase. Click in the Search Assemblies box in the top-right corner of the dialog and type "OpenXML" (without the quotes). The huge list of assemblies is filtered and just the one you want remains:

    Add Reference dialog filtered

    Double-clicking on the assembly in the list adds the reference and the little green icon appears next to it.

    Do the same for the Windowsbase assembly.

    Now you're going to create your first programmatically-generated OpenXML document.

    Switch to the DocGenerator class and add a couple of using directives:

    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;

    A very common pattern when creating OpenXML documents (and one used by the OpenXML SDK document reflector tool we'll see in a minute) is to create an OpenXML package with a using statement.

    In the CreateOneDocumentLocally method, delete the exception line (triple-click to select the entire line) and add the following:

    using (WordprocessingDocument package =
        WordprocessingDocument.Create("MyFirstDocument.docx",
        DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
    {
        
    }

    This has now created the outer container, or package (I'll examine some of the overloads of the Create method a bit later). Now you need to add some content to the package.

    The first thing to do is add a main document part – this is the bit that holds all of the text for the document. Inside the using statement's braces type

     

    package.AddMainDocumentPart();

     

    The MainDocumentPart has a document property which holds a reference to a Document class. Create one of those now:

    Document doc = new Document();

    The hierarchy of the Document object looks like this:

    Hierarchy of a document object

    So you'll new up one of each from the top down, and then append them back in the reverse order to build the hierarchy:

    Your method should look something like this:

     

    internal void CreateOneDocumentLocally()
    {
        using (WordprocessingDocument package =
            WordprocessingDocument.Create("MyFirstDocument.docx",
            DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
        {
            package.AddMainDocumentPart();

            // instantiate the members of the hierarchy
            Document doc = new Document();
            Body body = new Body();
            Paragraph para = new Paragraph();
            Run run = new Run();
            Text text = new Text() { Text = "The OpenXML SDK rocks!" };

            // put the hierarchy together
            run.Append(text);
            para.Append(run);
            body.Append(para);
            doc.Append(body);

            // Assign the document object to the MainDocumentPart's Document property

            package.MainDocumentPart.Document = doc;

        }
    }

     

    Moment of truth time – run the project and click the Create One Document Locally button. You should be rewarded with a MessageBox saying "Done".

    Close the form.

    Right-click on the project in Solution Explorer and choose "Open Folder in Windows Explorer".

    Navigate down into Bin/Debug.

    Double-click on MyFirstDocument.docx to open it in Word. With any luck, you should have something like this:

    Your first progromattically-generated OpenXML document

    Document Reflection Using the OpenXML SDK 2.0 Productivity Tool

    You'll have noticed that it still seemed to take a lot of code just to create a single sentence in a plain, un-themed document (although, I assure you, it's a lot less than you'd need to use if you called System.IO.Packaging directly). Fortunately, the OpenXML SDK ships with an all-purpose, Swiss Army Knife of a tool called the OpenXML SDK 2.0 Productivity Tool for Microsoft Office (I'm going to call it the OSDKT from now on). If you installed the SDK in the default location, the tool lives at C:\Program Files (x86)\Open XML SDK\V2.0\tool\OpenXmlSdkTool.exe. Take a moment now to fire it up. When it starts, it look like this:

    OpenXML SDK 2.0 Productivity Tool

    It's definitely worth checking out the documentation of this multi-purpose tool, but for now you'll just be using what I think is the most powerful feature, the Document Reflector. The Document reflector examines an OpenXML document and generates the code required to create the document programmatically. This means that you can start with a complex, beautifully themed document as a template, generate the code for that document and then adapt the code to include whatever makes sense (data from a database, web data, calculated information and so on).

    To reflect a document, click the Open File button in the OSDKT's toolbar and choose any OpenXML document. In this case, choose a Word document that doesn't support templates (usually with the extension docx). If you don't have one handy, I've uploaded one here for you to use.

    Notice that the hierarchy of the document is represented in the left side of the tool. In this screenshot I've expanded the hierarchy to show the MainDocumentPart, the Document, the Body, a Paragraph, a Run and a Text class.

    Open XML Hierarchy

    Note that there are lots of other nodes in the hierarchy that you didn't add in the first, hand-coded example you tried above.

    Now it's time to generate the code to create this document. Select the root node of the hierarchy in the left pane of the OSDKT and then click the Reflect Code button. After a few moments, the right pane fills up with what's known in the business as a shedload of code.

    Click somewhere in that code and then press Ctrl+A and then Ctrl+C to copy it all to the clipboard.

    Switch back to Visual Studio.

    Right-click on the project in the Solution Explorer and choose Add Class.

    Call the class DocumentCreator.

    Press Ctrl-A and Ctrl-V to replace the default code for the class with the code you copied from the OSDKT

    Change the NameSpace to OpenXMLDocumentGeneration and the class name to DocumentCreator. Your class definition should look something like this:

     

    using DocumentFormat.OpenXml.Packaging;
    using Ap = DocumentFormat.OpenXml.ExtendedProperties;
    using Vt = DocumentFormat.OpenXml.VariantTypes;
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Wordprocessing;
    using A = DocumentFormat.OpenXml.Drawing;
    using M = DocumentFormat.OpenXml.Math;
    using Ovml = DocumentFormat.OpenXml.Vml.Office;
    using V = DocumentFormat.OpenXml.Vml;
    using W14 = DocumentFormat.OpenXml.Office2010.Word;

    namespace OpenXMLDocumentGeneration
    {
        public class DocumentCreator
        {
            // Creates a WordprocessingDocument.
            public void CreatePackage(string filePath)
            {
                using (WordprocessingDocument package =
                    WordprocessingDocument.Create(filePath,
                    WordprocessingDocumentType.Document))
                {
                    CreateParts(package);
                }
            }

     

    Now all that needs to happen is to create and call this class instead of our hand-crafted code.

    In the DocGenerator class, add a field to hold a reference to an instance of our new DocumentCreator class as well as a base folder for output:

    Next, replace the contents of the CreateOneDocumentLocally method with a call to the DocumentCreator's CreatePackage method:

    Now remove the using directives that reference the OpenXML SDK namespaces as you don't need them in this class any more. The class should now look like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;

    namespace OpenXMLDocumentGeneration
    {
        class DocGenerator
        {
            DocumentCreator gen = new DocumentCreator();
            string OutputFolder = @"c:\temp\";

            internal void CreateOneDocumentLocally()
            {
                gen.CreatePackage(OutputFolder + "MyNextOpenXMLDocument.docx");
            }
        }
    }

    The last thing you'll do is add some code to time the creation of the document (so you can compare the different method calls later). In the Form1 code, instantiate a Stopwatch class and assign it to a field called sw then add code to reset and start the stopwatch before the document is created and to stop it and report the results when the method returns. Form1.cs should now look like this:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;

    namespace OpenXMLDocumentGeneration
    {
        public partial class Form1 : Form
        {
            DocGenerator gen = new DocGenerator();
            Stopwatch sw = new Stopwatch();

            public Form1()
            {
                InitializeComponent();
            }

            private void CreateOneDocumentLocallyButton_Click(object sender, EventArgs e)
            {
                sw.Reset();
                sw.Start();
                gen.CreateOneDocumentLocally();
                sw.Stop();
                MessageBox.Show(String.Format("Created one document locally in {0} ms",
                    sw.ElapsedMilliseconds));
            }
        }
    }

    Run this project up and click the Create One Document Locally button. In my case, this resulted in a MessageBox like this:
    Results of the first document creation run - 347ms

    Clicking it a couple more times gave interesting results:

    14ms 13ms

    Showing that time to actually create a document is pretty small – most of the time in the first instance is in instantiating the document creation classes.

    To show this even more vividly, add an event handler to the CreateManyDocumentsLocallyButton's click event that passes the value of the NumberOfDocs numericUpDown control to a method:

     

    private void CreateManyDocumentsLocallyButton_Click(object sender, EventArgs e)
    {
        sw.Reset();
        sw.Start();
        gen.CreateManyDocumentsLocally((int)NumberOfDocuments.Value);
        sw.Stop();
        MessageBox.Show(String.Format("Created {1} documents locally in {0} ms",
            sw.ElapsedMilliseconds, (int)NumberOfDocuments.Value));
    }

     

    CreateManyDocumentsLocally just loops through and creates that may documents:

     

    internal void CreateManyDocumentsLocally(int NumberOfDocs)
    {
        for (int i = 0; i < NumberOfDocs; i++)
        {
            gen.CreatePackage(string.Format("{0}MyNextOpenXMLDocument{1:D5}.docx",
                OutputFolder, i));
        }

    }

     

    Running this with 100 documents gave me this:

    100 documents too 1828 ms

    and with 1000 documents

    Creating 1000 documents locally took 14935 ms

    Finally, try using the new Parallel Task Library:

     

    internal void CreateManyDocumentsLocallyInParallel(int NumberOfDocs)
    {
        System.Threading.Tasks.Parallel.For(0, NumberOfDocs, i =>
        {
            gen.CreatePackage(string.Format("{0}MyNextOpenXMLDocument{1:D5}.docx",
                OutputFolder, i));
        });

    }

     

    and update the Form1 code that calls it to look like:

     

    private void CreateManyDocumentsLocallyButton_Click(object sender, EventArgs e)
    {
        sw.Reset();
        sw.Start();
        gen.CreateManyDocumentsLocallyInParallel((int)NumberOfDocuments.Value);
        sw.Stop();
        MessageBox.Show(String.Format("Created {1} documents locally with Parallel Processing in {0} ms",
            sw.ElapsedMilliseconds, (int)NumberOfDocuments.Value));
    }

     

    Calls to 100 and 1000 documents with Parallel processing on my quad core box only gave me about a 50% increase in performance:

    Creating 100 docs in parallel took 1481 ms Creating 1000 documents in parallel took 8992 ms

    Tune in next time

    This concludes Part 1. In Part 2, I'll explore writing the documents to a SharePoint library instead of to a local file system and then converting the documents from docx to pdf files with no user intervention at all!

    Additional Resources

    Download the SharePoint 2010 Developer Training Kit

     

  • Andrew Coates ::: MSFT

    TechEd Australia 2010 Call for Topics

    • 0 Comments

    TechEd Australia 2010

    Once again I've been "blessed" with the content owner role for TechEd Australia 2010 which is on the Gold Coast from August 24-27.

    Our Call for Topics is now open (and will probably close around June 12). If you're interested in speaking at TechEd Australia (and possibly New Zealand), please check the Terms and Conditions and then submit as many topics as you'd be interested in presenting in one or more of the 14 Technical Tracks.

    One interesting thing to note is that we have a new track this year – the Voice of the Customer. We're looking for 8 great warts-and-all case studies showcasing how real-world problems have been solved with Microsoft and other technologies.

    The tracks and their owners/tech advisors are as follows:

    Track Owner Content Advisor(s)
    Architecture Nigel Watson  
    Cloud Computing and Online Services Greg Willis  
    Data Platform and Business Intelligence Marcy Larsen Ron Dunn
    Developer Tools, Languages and Frameworks Dave Glover  
    Dynamics Ross Dembecki Catherine Eibner
    Management Frederique Dennison Andrew McMurray
    Office and SharePoint Sophie Corker Alistair Speirs, William Cornwall, Gayan Peiris
    Security, Identity and Access Frederique Dennison Rocky Heckman, Jamie Sharp
    Unified Communications Johann Kruse  
    Virtualisation Rosemary Stark Philip Duff
    Voice of the Customer Charlie Annetta  
    Web Platform Michael Kordahi  
    Windows Client Danny Beck John Pritchard, Daniel Bucherer
    Windows Phone Sheau-Lan Reed Dave Glover
    Windows Server Rosemary Stark Jeff Alexander

    Have at it!

  • Andrew Coates ::: MSFT

    Windows Azure User Group Briefings

    • 0 Comments

    Dave Lemphers comin' atchya

    The one and only Dave Lemphers is coming back to Australia for a week at the end of February for a whirlwind tour of the country to coincide with the launch in Australia of Windows Azure. He'll be doing public technical briefings hosted by the user groups in 5 capital cities.

    Date/Time City Details
    Mon 22 Feb 12:00-13:30 Adelaide Microsoft Innovation Centre
    Level 2, Westpac House
    91 King William Street Adelaide SA 5000
    Register Here
    Tue 23 Feb 18:00-20:30 Melbourne Microsoft Theatre
    Level 5, 4 Freshwater Place,
    Southbank, VIC
    Wed 24 Feb 12:00-13:00 Brisbane Microsoft Theatres
    Level 9, Waterfront Place
    1 Eagle Street
    Brisbane
    Thu 25 Feb 12:00-13:00 Canberra Microsoft Theatre
    Level 2, Walter Turnbull Building,
    44 Sydney Avenue,
    Barton, ACT 2600
    Thu 25 Feb 18:30-20:30 Sydney Microsoft Theatres
    1 Epping Rd
    NORTH RYDE NSW 2113

    If/when there are registration links for the events in the other 4 cities, I'll update them here. Otherwise, just rock up at the date/time above.

    For more details about Windows Azure in Australia, see Greg Willis' post from last month.

    Windows Azure Logo

  • Andrew Coates ::: MSFT

    NXT2.0 Robot - The Journey Continues

    • 1 Comments

    In my previous post, I talked about getting a new Lego Mindstorms NXT 2.0 robotics kit and about building TrophyBot to carry around a Lego trophy Catherine Eibner won for being an awesome evangelist. In this post, as promised, I'll talk about how I programmed the robot to move around, shouting "HORRAY!" whenever it bumped into anything.

    The Lego Mindstorms NXT software is a really nice piece of work. It's a Flash player preloaded with the always excellent step-by-step instructions for building four very cool robots, a vehicle (ShooterBot), an animal (Robogator), a machine (Color Sorter) and a humanoid (Alpha Rex). Lego instructions are exceptionally thorough, which means that even a novice can construct a working robot in fairly short order.

    Step-by-step instrcutions

    Aside: I've been thinking a bit about the corollary between these step-by-step logo instructions and how I started programming, which was copying 100 or so lines of code out of a magazine to do <insert inane or mundane thing here>. Having something to copy meant that I had a base to experiment from, to draw conclusions about and to formulate patterns around. I could generalise and improvise. This fed my curiosity far more than I see my childrens' being fed by the current "download 1000 lines and a couple of libraries from the internet". I think that actually typing in the code and fixing the inevitable typos gave me more insight. I've noticed this trait in my kids though when they build Lego. The instructions are very clear, but they have to execute every one of them to make the robot (or what ever they're building) work. They're much more familiar with it than if I'd built it for them and said "have a look at this and see how it works". My gut feel (completely devoid of any science) is that their curiosity is awakened by the feeling of ownership and achievement that comes with building it themselves.

    I used the first section of Shooterbot - the driving base - for Trophybot

    Shooterbot Driving Base

    To this I needed to add a bump sensor (so Trophybot could detect and move away from obstacles) and a platform to hold the trophy.

     

    Trophybot platform Trophybot bump sensor 

    Ignore the ultrasonic sensor (that looks like a pair of eyes), it's not used at this stage.

    The next step was to actually make Trophybot do something. First, I had to connect the NXT to the computer. There are a couple of ways to do this, either tether via USB or connect via Bluetooth. the instructions for both are pretty straightforward, so I did both.

    Now it was time to write the first bit of code. In fact, using the NXT software, it's actually a matter of assembling and wiring together programming blocks. Initially, I just wanted Trophybot to go forwards and I'd manually pick it up and turn it off.

    I created a new program called, originally enough, "Go Forward" and was presented with a blank canvas:

    Starting a new mindstorms program

    I grabbed the Move block from the top of the toolbar and dropped it where it says "Start". When the new block's selected, a properties pane appears at the bottom of the screen to let you set properties for that block. I set the duration property to Unlimited and hit the download button.

    Go forward - first draft

    I pressed the orange button on the NXT brick 4 times to run the program I'd just downloaded and nothing happened - hmm.

    OK - maybe the environment's smart enough not to get into an infinite loop, so I added some logic - what I thought might be a sensible way to represent an event (in this case, the sensor getting pressed). I chose the complete palette in the blocks toolbox and dropped a touch sensor on the canvas. I didn't connect it to anything because I figured this would be an event that happened and broke into whatever was going on at the time.

    Sensor event?

    The sensor block stayed greyed-out, which I guessed meant that it wouldn't be used. More work needed.

    Next I tried putting all the logic in a loop that polled the state of the sensor each iteration and then took the appropriate action.

    Move and check in a loop

    This says:

    Loop
      If sensor not pressed or bumped 
        Go forward 1 second
      Else
        Go back 1 revolution
        Turn right 1 revolution
      EndIf
    End Loop

    Which at least made the robot move but it had two drawbacks:

    1. It moved forward in 1 second jerks followed by a small break; and
    2. It didn't react to a bump or press until the second of forward motion was done.

    Interestingly, the way to fix this is to make the motion in the top part of the loop unlimited instead of making it a specific duration. The unlimited move block is a special case that actually means keep moving until the condition at the start of the loop changes. It also doesn't work outside a loop (which is why my first, single block, program failed) because it "falls through immediately to the next step.

    Finally, I added some randomness to the program that meant that the robot turns in a random direction and a random number of degrees when it hits something. This seems to give it more of a chance to get out of corners and away from complex obstacles. I also added a play sound block to make the bot say "Horray!" whenever it bumped into something.

    The final program looks like this:

    TrophyBot final program

    All-in-all, this was a really fun start to what's going to be a much longer term project. I've managed to acquire a Lego Technics truck that is ripe for roboticising and I'm looking forward to having a play with the .NET programming environment provided by Microsoft Robotics Studio.

    I'll keep you in the (infinite) loop.

    All-in-all

  • Andrew Coates ::: MSFT

    Test Post from Word 2010

    • 0 Comments

    I've not posted from Word 2010 before (I prefer Live Writer), but I had a question from a colleague as to how to set it up. If this appears, it looks like I managed.

  • Andrew Coates ::: MSFT

    Lego Mindstorms NXT2.0 - TrophyBot

    • 2 Comments

    Lego Mindstorms NXT2.0 Box

    For some time now, I've coveted the Lego Mindstorms NXT 2.0 Robotics kit. It's a great teaching toy tool and not only can you program it with the excellent and intuitive Lego IDE (from LabView), but you can also use Microsoft Robotics Studio and .NET.

    With that justification, just before Christmas I ordered one from the local online Lego Specialist, BrickNet and immediately got an email from them saying they'd shipped it. As soon as I got back to work after New Year, it was waiting on my desk. Awesome!

    Lego Mindstorms NXT2.0 Contents

    There are over 600 pieces in the box ranging from the main brick (the NXT Controller) that's the brains of any robot you build, the motors cables and sensors that are the brawn and nervous system:

    NXT2.0 COntroller Motors, cables and sensors

    The traditional Lego Technics bits and the test pad are accompanied by a CDROM and instruction manual

    Lego Bits Test Pad 

    Of course, when they arrive, they're all packed in the box like this:

    Original packing configuration

    Having built Technics kits before, I know how important it is to be able to find that tiny piece without which the whole thing just won't work, so the first thing I did was go down to the local supermarket and buy a heap of plastic sealable containers in various sizes and spend the next 90 minutes or so sorting bits into boxes. Yes, I know there's a name for my condition and thanks, the therapy is proceeding apace. In the end, it looked like this:

    Reboxed and ready to start

    So the question was, of course, what to build first. Some of you may have caught the news that Catherine Eibner was recently awarded the Microsoft Diversity Campion Women Build Award for 2009. Of course, the trophy she got was all lego (as were the dozen or so "mini-me" lego people that went along with it.

    Mini-ceibnerMini-ceibner from behind

    Catherine's Trophy

    Sadly, not everyone in the subsidiary reads Catherine's blog, and so they might not have found out about this important award being presented to someone so close to them.

    What better way to solve that problem than to have a robot take them the news. Enter TrophyBot:

    TrophyBot front view

    TrophyBot is an extension of the first tutorial robot that ships with the Mindstorms kit. The driving base consists of 2 motors to propel the tracks and the NXT controller. A third motor is built in to the centre of the body to provide for later upgrades.

    Building the base is pretty straight forward, the detailed step-by-step instructions are available in the printed manual or as part of the NXT software that comes in the kit.

    instructions screenshot

    In addition to the driving base (shown in the top-left of the screenshot above), I added a platform for the trophy to stand on, a bump sensor to work out when the robot hits things and an ultrasonic sensor to detect things that are further away.

     TrophyBot right side TrophyBot rear view TrophyBot left side

    In a subsequent post I'll show how easy it is to program TrophyBot, to respond to events and to interact with the environment.

  • Andrew Coates ::: MSFT

    SharePoint Saturday Perth event

    • 1 Comments

    SharePoint Saturday has reached Australia recently with the efforts of Brian Farnhill and Ben Walters in both Melbourne and Sydney. Jeremy Thake from Perth SharePoint User Group thought it was about time it happened in Perth with the help of other volunteers.

    The event is provisionally announced for the 6th February 2010, awaiting confirmation from the Venue management team at Cliftons in Perth on the Terrace.

    Please contact the #SPSPerth committee by sending an email to spsperth@made4the.net.

    They are currently looking for expressions of interest to both attend, speak and sponsor the event by filling out this survey.

    Please bookmark the site, subscribe to the announcements RSS feed and follow @SPSPerth on Twitter, keep track of the #SPSPerth hash tag on Twitter to keep up to date with announcements!

Page 8 of 47 (470 items) «678910»