
   // document.write('<script type="text/javascript" src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>\n');
   // document.write('<script type="text/javascript" src="http://cdn.robotwebtools.org/roslibjs/current/roslib.min.js"></script>\n');

    var ros = new ROSLIB.Ros({
    url : 'ws://192.168.43.20:9090'
});

    ros.on('connection', function() {
    console.log('Connected to websocket server.');
});

    ros.on('error', function(error) {
    console.log('Error connecting to websocket server: ', error);
});

    ros.on('close', function() {
    console.log('Connection to websocket server closed.');
});
   var move_base= new ROSLIB.ActionClient({
       ros : ros,
       serverName : '/move_base',
       actionName : 'move_base_msgs/MoveBaseAction'
   });

   var currentTime = new Date();
   var secs = Math.floor(currentTime.getTime()/1000)
   var nsecs = Math.round(1000000000*(currentTime.getTime()/1000-secs))

   var goal = new ROSLIB.Goal({
       actionClient: move_base,
       goalMessage:{
           target_pose:{
               header:{
                   frame_id:'map',
                   stamp:{
                       secs: secs,
                       nsecs:nsecs
                   }
               },
               pose:{
                   position:{
                       x:-3.97,   //-0.743    -0.0273   取件点
                       y:1.68,  //3.00        -0.09
                       z:0.000
                   },
                   orientation:{
                       x:0.000,
                       y:0.000,
                       z:0.000,
                       w:1.000
                   }
               }
           }
       }
   });
   goal.on('feedback', function(feedback) {
       console.log('Feedback: ' + feedback.sequence);
   });

   goal.on('result', function(result) {
       console.log('Final Result: ' + result.sequence);
   });

   ros.on('connection', function() {
       console.log('Connected to websocket server.');
   });

   ros.on('error', function(error) {
       console.log('Error connecting to websocket server: ', error);
   });

   ros.on('close', function() {
       console.log('Connection to websocket server closed.');
   });

   //goal.send();
    var cmdVel = new ROSLIB.Topic({
        ros : ros,
        name : '/cmd_vel',
        messageType : 'geometry_msgs/Twist'
    });

    var twist = new ROSLIB.Message({
        linear : {
            x : 0.1,
            y : 0.2,
            z : 0.3
        },
        angular : {
            x : -0.1,
            y : -0.2,
            z : -0.3
        }
    });
    cmdVel.publish(twist);

