Loading ...
Sorry, an error occurred while loading the content.

Wireless and motion commands tutorial

Expand Messages
  • kpw_km
    I m trying to write a new behavior getting data from a dos console, but getting lost. Can anyone have the tutorail like the ones in Tekotsu web site on that
    Message 1 of 4 , Jan 2, 2004
    • 0 Attachment
      I'm trying to write a new behavior getting data from a dos console,
      but getting lost.

      Can anyone have the tutorail like the ones in Tekotsu web site on
      that issue.

      I still can't save the position files yet even though I changed the
      memory stick and check the directory on memory stick.

      --KaiMing
    • Ethan Tira-Thompson
      ... how much data? From someone typing? If so, I d say have your behavior listen for text message events. There s three cases depending on whether you want
      Message 2 of 4 , Jan 3, 2004
      • 0 Attachment
        > I'm trying to write a new behavior getting data from a dos console,
        > but getting lost.
        how much data? From someone typing? If so, I'd say have your behavior
        listen for text message events.
        There's three cases depending on whether you want to use the
        ControllerGUI.
        If you have the ControllerGUI connected:
        - type '!msg blahblah' in the input field
        - telnet to port 10001 and type anything (followed by a return)
        If you don't have the ControllerGUI connected:
        - telnet to port 10001 and type '!msg blahblah'

        The idea is that if you don't have the GUI open, the controller will
        listen for console input on 10001. But if the GUI is open, it doesn't
        need the port, so anything that is received there is sent out to
        behaviors as a text message.


        > Can anyone have the tutorail like the ones in Tekotsu web site on
        > that issue.
        There's a little bit about this here:
        http://www-2.cs.cmu.edu/~tekkotsu/Wireless.html
        but I should expand on the part about text message events.
        I don't really know enough about what you're trying to do to give a
        how-to. If you want to open a new port for network interface, you'll
        need to look at the Wireless and Socket classes - a tutorial might be a
        good idea for that, but since i won't have time for it any time very
        soon, the source documentation and looking at how other classes handle
        it will have to do for now... (look in Behaviors/Mon for example code)

        > I still can't save the position files yet even though I changed the
        > memory stick and check the directory on memory stick.
        Has anyone else had trouble with this? I'm out of ideas and can't
        replicate the problem.
        You may just have to dip into the PostureEngine code and dump it to
        console or something instead of to a file.
      • kpw_km
        Hi.. what I m trying to do is to listen a keyboard press and change the posture of Aibo into sitting position. Well, I look into Aibo3Dcontroller.h and tried
        Message 3 of 4 , Jan 5, 2004
        • 0 Attachment
          Hi..

          what I'm trying to do is to listen a keyboard press and change the
          posture of Aibo into sitting position. Well, I look into
          Aibo3Dcontroller.h and tried to repliacte a class.

          But, the Aibo crash whenever I load the behaviour in startup.

          Anything wrong...

          Best regards,
          Kai Ming

          The following is what I tried so far...I even disabled the wireless
          one for the time being to narrow down the problem. But it still
          crash. Just no idea. It is exactly the same as aibo3Dcontroller code.



          //-*-c++-*-
          #ifndef INCLUDED_GoingtoSit_h_
          #define INCLUDED_GoingtoSit_h_

          #include <iostream>
          #include "Wireless/Wireless.h"
          #include "Behaviors/BehaviorBase.h"
          #include "Motion/MotionManager.h"
          #include "Motion/RemoteControllerMC.h"
          #include "Events/EventRouter.h"
          #include "Events/EventBase.h"
          #include "Shared/RobotInfo.h"
          #include "Behaviors/Controller.h"
          #include "Shared/WorldState.h"

          //! gets input from the GUI
          int sitting_callback(char *bufer, int bytesno);
          class GoingtoSit;

          //! so aibo3dcontrollercmd_callback knows where to send the input
          from the GUI
          GoingtoSit *goingtoSit = NULL;


          //! Listens to aibo3d control commands coming in from the command
          port.
          class GoingtoSit : public BehaviorBase {
          protected:
          //MotionManager::MC_ID rcontrol_id; //!< remote controller
          motion command's id

          //! The input command stream socket
          //Socket *cmdsock;

          //float val[NumPIDJoints]; //!< the value to use for each of the
          PID joints
          //char *fbuf; //!< alias to val
          //unsigned int pos; //!< a counter to know when we've gotten 4
          frames

          private:
          GoingtoSit(const GoingtoSit&); //!< don't call
          GoingtoSit operator=(const GoingtoSit&); //!< don't call

          public:
          //! constructor
          GoingtoSit() :
          BehaviorBase()
          //cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048,
          2048))
          {
          // wireless->setDaemon(cmdsock);
          goingtoSit = this;
          }
          //! destructor
          virtual ~GoingtoSit() { goingtoSit = NULL; }

          //! processes input from the GUI
          /*int registerData(char *buffer, int bytesno) {
          printf("I received\n");
          return 1;
          }*/

          /*void updateRC() {
          RemoteControllerMC *rcontrol = (RemoteControllerMC*)
          motman->checkoutMotion(rcontrol_id);
          for (unsigned int i=0; i<NumPIDJoints; i++)
          rcontrol->cmds[i]=val[i];
          rcontrol->setDirty();
          motman->checkinMotion(rcontrol_id);
          }*/

          //this code is added by KM to test out the received values.
          /*void printout(){
          printf("One chunk\n");
          for (unsigned int i=0; i<NumPIDJoints; i++)
          printf("%f\n", val[i]);
          }*/

          virtual void DoStart() {
          // Behavior startup
          BehaviorBase::DoStart();

          // Enable remote control stream
          //rcontrol_id = motman->addMotion
          (SharedObject<RemoteControllerMC>());
          //updateRC();
          // Turn on wireless
          // wireless->setReceiver(cmdsock->sock,
          sitting_callback);
          // wireless->listen(cmdsock->sock, config-
          >main.toSit_port);
          printf("Do start");
          // open gui
          /* std::vector<std::string> tmp;
          tmp.push_back("Aibo3D Load
          Instructions");
          tmp.push_back("To load
          Aibo3D, you will need to install java3d\nand then run
          Tekkotsu/tools/aibo3d/");
          tmp.back()+=getGUIType();
          Controller::loadGUI
          ("ControllerMsg","LoadAibo3d",getPort(),tmp);*/
          //Controller::loadGUI(getGUIType(),getGUIType
          (),getPort());
          }

          virtual void DoStop() {
          //Controller::closeGUI(getGUIType());
          // Close socket; turn wireless off
          //wireless->close(cmdsock);
          // Disable remote control
          //motman->removeMotion(rcontrol_id);
          // Total behavior stop
          BehaviorBase::DoStop();
          }

          //! returns string corresponding to the Java GUI which
          should be launched
          //virtual std::string getGUIType() const {
          return "org.tekkotsu.aibo3d.Aibo3DPick"; }
          //! returns port number the Java GUI should connect to
          virtual unsigned int getPort() const { return config-
          >main.toSit_port; }

          virtual std::string getName() const {
          return "GoingtoSit"; } //!< returns name of behavior
          static std::string getClassDescription() {
          char tmp[20];
          sprintf(tmp,"%d",config->main.toSit_port);
          return std::string("Commanding the Aibo to sit ")
          +tmp;
          }
          };


          /*int sitting_callback(char *bufer, int bytesno) {
          if (goingtoSit!=NULL)
          return goingtoSit->registerData(bufer, bytesno);
          return 0;
          }*/

          /*! @file
          * @brief Defines Aibo3DControllerBehavior, which listens to
          commands from the Aibo3D gui and shows current state
          * @author alokl (Creator)
          *
          * $Author: ejt $
          * $Name: tekkotsu-1_5 $
          * $Revision: 1.1 $
          * $State: Rel $
          * $Date: 2003/10/10 00:45:01 $
          */

          #endif
        • Ethan Tira-Thompson
          hmm, i dunno... with all the commented out stuff removed, it boils down to this, right? virtual void DoStart() { BehaviorBase::DoStart(); printf( Do start );
          Message 4 of 4 , Jan 5, 2004
          • 0 Attachment
            hmm, i dunno... with all the commented out stuff removed, it boils down to this, right?

              virtual void DoStart() {
                BehaviorBase::DoStart();
                printf("Do start");  //
            you might want to add a '/n'
              }

              virtual void DoStop() {
                BehaviorBase::DoStop();
              }


            that should be no problem at all.  I'm thinking the crash might be from something outside the behavior?  Try putting a for loop in front of the printf.  Make it output a few hundred times to make sure the buffer gets flushed to your console before the crash occurs.

            More importantly, try running the crashDebug tool from within your project directory (and the memory stick in the drive) right after a crash - it should give you a stack trace so you can determine where/why the crash occurred.

            -ethan
          Your message has been successfully submitted and would be delivered to recipients shortly.