none
Lego NXT Motor Encoder Updates RRS feed

  • Question

  • Hello there!

    I'm programming a Lego NXT at the moment and I have one motor that turns the ultrasonic sensor around. When I send requests to the motor to turn, it proceeds to turn but I get errors thrown saying that there is no handler for the UpdateTickCountRequest. What I have done is tried to make a handler to handle these updates (and also so I can find out the state of the motor). I have done a handler for the Drive service and it was pretty straightforward. The problem is that I cant seem to register a handler for the single motor as there seems to be no MotorEncoderUpdate type as there is with the Drive service.

    I have had a look at implementing this generic encoder (http://social.msdn.microsoft.com/forums/en-US/roboticstroubleshooting/thread/7f824db1-c866-4516-8f0d-51cfe7187c5c/ ) as I understand that might solve my problem - but this post is very old from 2007.. Is this still the way it is done because I have tried to implement it but it doesn't get rid of my errors - throws a new one "PortMode.OptimizedSingleReissueReceiver allows only a single receiver" 

    Here is some of my code:

                [Partner("NxtMotor", Contract = motor.Contract.Identifier,
                CreationPolicy = PartnerCreationPolicy.UseExistingOrCreate)]
            private motor.MotorOperations _nxtMotorPort =  new motor.MotorOperations();
    
            private motor.MotorOperations _nxtMotorNotify = new motor.MotorOperations();
    
            [Partner("NxtMotorEncoder", Contract = encoder.Contract.Identifier, CreationPolicy = PartnerCreationPolicy.UsePartnerListEntry)]
            encoder.EncoderOperations _nxtMotorEncoderPort = new encoder.EncoderOperations();
            encoder.EncoderOperations _nxtMotorEncoderNotify = new encoder.EncoderOperations();
         
    
    
     var sub2 = _nxtMotorEncoderPort.Subscribe(_nxtMotorEncoderNotify);
                yield return (Choice)sub2;
                var fa = (Fault)sub2;
                if (fa != null)
                {
                    LogError(fa);
                    StartFailed();
                    yield break;
                }

     base.MainPortInterleave.CombineWith(
                    new Interleave(
                        new ExclusiveReceiverGroup(
                            Arbiter.ReceiveWithIterator<sonarsensor.SonarSensorUpdate>(true, _nxtUltrasonicSensorNotify,
                                                                                       nxtUltrasonicSensorUpdateHandler),
                            Arbiter.ReceiveWithIterator<touchsensor.TouchSensorUpdate>(true, _nxtTouchSensor1Notify, TouchHandler1),
                            Arbiter.ReceiveWithIterator<touchsensor.TouchSensorUpdate>(true, _nxtTouchSensor2Notify, TouchHandler2)
                                 
                            //Arbiter.ReceiveWithIterator<touchsensor.TouchSensorUpdate>(true, _nxtTouchSensor1Notify,
                                 //                                                      nxtTouchSensor1UpdateHandler),
                                                                     ),
                        new ConcurrentReceiverGroup(
                           
                         // Arbiter.Receive<encoder.UpdateTickCountRequest>(true, _nxtMotorEncoderPort, MotorHeadEncoderUpdate),
                            Arbiter.Receive<motor.MotorState>(true, _nxtMotorNotify, MotorHeadEncoderUpdate),
                            Arbiter.Receive<drive.DriveEncodersUpdate>(true, _nxtDriveNotify, DriveEncoderHandler),
                            Arbiter.Receive(true, _timerPort, TimerHandler)
                             //    )
                            )
                        )
                    );

    The error that it throws when there is no handler registered for the motor is the following:

    *   Moving head left [07/05/2012 08:57:14][http://127.0.0.1:50000/robotdogdssservice/ba9264fe-5b45-4d0c-95dc-e940d85dbe6f]
    *** ### DsspForwarder: InboundException. Exception: System.Exception: Body type not expected:Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     || Action: http://schemas.microsoft.com/xw/2004/10/dssp.html:NotifyRequest.
     || Body Type: Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest.
     || Target Service: dssp.tcp://127.0.0.1:50001/robotdogdssservice/ba9264fe-5b45-4d0c-95dc-e940d85dbe6f/dss/notificationtarget/c93c7e59-5a0a-4f2a-b5b2-ef347873df8c.
     || Source Service: dssp.tcp://127.0.0.1:50001/lego/nxt/motor/3128cd7a-dd41-40d2-838b-87d72cc1cf32.
     || Exception Stack Trace:    at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     [07/05/2012 08:57:15][]
    *** ### DsspForwarder: InboundException. Exception: System.Exception: Body type not expected:Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     || Action: http://schemas.microsoft.com/xw/2004/10/dssp.html:NotifyRequest.
     || Body Type: Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest.
     || Target Service: dssp.tcp://127.0.0.1:50001/robotdogdssservice/ba9264fe-5b45-4d0c-95dc-e940d85dbe6f/dss/notificationtarget/c93c7e59-5a0a-4f2a-b5b2-ef347873df8c.
     || Source Service: dssp.tcp://127.0.0.1:50001/lego/nxt/motor/3128cd7a-dd41-40d2-838b-87d72cc1cf32.
     || Exception Stack Trace:    at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     [07/05/2012 08:57:15][]

    Any help would be greatly appreciated! thanks!

    Sunday, July 22, 2012 2:41 PM

Answers

  • You need a handler for UpdateTickCount notification. (Not UpdateTickCountRequest).

    Activate(Arbiter.Receive<encoder.UpdateTickCount>(false, notificationPort,EncoderUpdateTickCountHandler ));

    IEnumerator<ITask> EncoderUpdateTickCountHandler(pxencoder.UpdateTickCount update)

    {

    ..

    }

    Friday, July 27, 2012 7:46 PM
    Moderator

All replies

  • You need a handler for UpdateTickCount notification. (Not UpdateTickCountRequest).

    Activate(Arbiter.Receive<encoder.UpdateTickCount>(false, notificationPort,EncoderUpdateTickCountHandler ));

    IEnumerator<ITask> EncoderUpdateTickCountHandler(pxencoder.UpdateTickCount update)

    {

    ..

    }

    Friday, July 27, 2012 7:46 PM
    Moderator
  • Thank you this worked - the only problem is that I am still getting a few errors thrown about this UpdateTickCountRequest. I have registered the handlers and can receive the UpdateTickCount values and executes the handler code but still receiving errors saying that I have not registered a handler for the type of message.

    Do you have any idea as to why I am getting these errors? I registered the handler as part of the Concurrent Receiver group.

    *** ### DsspForwarder: InboundException. Exception: System.Exception: Body type not expected:Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     || Action: http://schemas.microsoft.com/xw/2004/10/dssp.html:NotifyRequest.
     || Body Type: Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest.
     || Target Service: dssp.tcp://127.0.0.1:50001/robotdogdssservice/36c20ee9-4e13-4113-ab69-04e830bd3219/dss/notificationtarget/39dc3e64-5341-4c7e-b1a1-deba06b00989.
     || Source Service: dssp.tcp://127.0.0.1:50001/lego/nxt/motor/82792557-8c41-4f9f-bb31-9907c83e4db0.
     || Exception Stack Trace:    at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     [07/30/2012 08:46:38][]
    *** ### DsspForwarder: InboundException. Exception: System.Exception: Body type not expected:Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     || Action: http://schemas.microsoft.com/xw/2004/10/dssp.html:NotifyRequest.
     || Body Type: Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest.
     || Target Service: dssp.tcp://127.0.0.1:50001/robotdogdssservice/36c20ee9-4e13-4113-ab69-04e830bd3219/dss/notificationtarget/66733edf-eca7-474c-a01e-8a4c08ca2e0c.
     || Source Service: dssp.tcp://127.0.0.1:50001/lego/nxt/motor/82792557-8c41-4f9f-bb31-9907c83e4db0.
     || Exception Stack Trace:    at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     [07/30/2012 08:46:38][]
    *** ### DsspForwarder: InboundException. Exception: System.Exception: Body type not expected:Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     || Action: http://schemas.microsoft.com/xw/2004/10/dssp.html:NotifyRequest.
     || Body Type: Microsoft.Robotics.Services.Encoder.Proxy.UpdateTickCountRequest.
     || Target Service: dssp.tcp://127.0.0.1:50001/robotdogdssservice/36c20ee9-4e13-4113-ab69-04e830bd3219/dss/notificationtarget/39dc3e64-5341-4c7e-b1a1-deba06b00989.
     || Source Service: dssp.tcp://127.0.0.1:50001/lego/nxt/motor/82792557-8c41-4f9f-bb31-9907c83e4db0.
     || Exception Stack Trace:    at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.ConvertSoapEnvelopeToDsspOperation(PortWithConfiguration portConfig, String action, ForwarderEnvelope msg, IPort& targetPort)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundNotificationHandler(ForwarderEnvelope msg)
       at Microsoft.Dss.Services.Forwarders.Dssp.DsspForwarder.InboundHandler(ForwarderEnvelope msg).
     [07/30/2012 08:46:38][]

    Thank you for your help so far.

    Monday, July 30, 2012 8:52 AM