亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 3dmg.cc

?? 機器人仿真平臺,和stage配合運行
?? CC
字號:
/* *  Player - One Hell of a Robot Server *  Copyright (C) 2000   *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard *                       *  *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *//* * Desc: Driver for the MicroStrain 3DM-G IMU * Author: Andrew Howard * Date: 19 Nov 2002 * CVS: $Id: 3dmg.cc,v 1.2 2002/11/29 18:02:39 gerkey Exp $ */#if HAVE_CONFIG_H  #include <config.h>#endif//#include <assert.h>#include <errno.h>#include <fcntl.h>#include <math.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <termios.h>#include <unistd.h>#include <netinet/in.h>#include "playercommon.h"#include "drivertable.h"#include "player.h"#include <playertime.h>extern PlayerTime* GlobalTime;// MicroStraing 3DM-G IMU driverclass MicroStrain3DMG : public CDevice{  // Constructor  public: MicroStrain3DMG(char* interface, ConfigFile* cf, int section);  // Initialise device  public: virtual int Setup();  // Shutdown the device  public: virtual int Shutdown();  // Main function for device thread.  private: virtual void Main();  // Open the serial port  // Returns 0 on success  private: int OpenPort();  // Close the serial port  // Returns 0 on success  private: int ClosePort();  // Read the firmware version  private: int GetFirmware(char *firmware, int len);  // Read the stabilized acceleration vectors  private: int GetStabV(double *time, double v[3], double w[3]);  // Read the stabilized orientation matrix  private: int GetStabM(int M[3][3]);  // Read the stabilized orientation quaternion  private: int GetStabQ(double *time, double q[4]);  // Send a packet and wait for a reply from the IMU.  // Returns the number of bytes read.  private: int Transact(void *cmd, int cmd_len, void *rep, int rep_len);      // Name of port used to communicate with the laser;  // e.g. /dev/ttyS1  private: const char *port_name;  // Port file descriptor  private: int fd;};// Factory creation functionCDevice* MicroStrain3DMG_Init(char* interface, ConfigFile* cf, int section){  if(strcmp(interface, PLAYER_POSITION_STRING))  {    PLAYER_ERROR1("driver \"MicroStrain3DMG\" does not support interface \"%s\"\n",                  interface);    return(NULL);  }  else    return ((CDevice*) (new MicroStrain3DMG(interface, cf, section)));}// Driver registration functionvoid MicroStrain3DMG_Register(DriverTable* table){  table->AddDriver("microstrain3dmg", PLAYER_READ_MODE, MicroStrain3DMG_Init);}////////////////////////////////////////////////////////////////////////////////// IMU codes#define CMD_NULL      0x00#define CMD_VERSION   0xF0#define CMD_INSTANTV  0x03#define CMD_STABV     0x02#define CMD_STABM     0x0B#define CMD_STABQ     0x05#define TICK_TIME     6.5536e-3#define G             9.81////////////////////////////////////////////////////////////////////////////////// ConstructorMicroStrain3DMG::MicroStrain3DMG(char* interface, ConfigFile* cf, int section)    : CDevice(sizeof(player_position_data_t), 0, 0, 0){  // Default serial port  this->port_name = cf->ReadString(section, "port", "/dev/ttyS1");  return;}////////////////////////////////////////////////////////////////////////////////// Set up the deviceint MicroStrain3DMG::Setup(){     printf("IMU initialising (%s)\n", this->port_name);      // Open the port  if (OpenPort())    return -1;    // Start driver thread  StartThread();  return 0;}////////////////////////////////////////////////////////////////////////////////// Shutdown the deviceint MicroStrain3DMG::Shutdown(){  // Stop driver thread  StopThread();  // Close the port  ClosePort();  return 0;}////////////////////////////////////////////////////////////////////////////////// Main function for device threadvoid MicroStrain3DMG::Main() {  int i;  double ntime, dt;  double al[3], ar[3];  double vl[3], vr[3];  double pl[3], pr[3];  double q[4];  double m;  double e[3];  struct timeval time;  player_position_data_t data;    for (i = 0; i < 3; i++)  {    vr[i] = 0.0;    pr[i] = 0.0;  }    while (true)  {    // Test if we are supposed to cancel    pthread_testcancel();    GetStabQ(&ntime, q);        m =  q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3];            //printf("%+6.3f %+6.3f %+6.3f %+6.3f, %+6.3f\n", q[0], q[1], q[2], q[3], m);    e[0] = 0.0;    e[1] = 0.0;    e[2] = atan2(2 * (q[1] * q[2] + q[0] * q[3]),                 (q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3]));    // BROKEN    //e[1] = asin(-2 * (q[0] * q[2] - q[3] * q[1]));    //e[0] = atan(2 * (q[3] * q[0] + q[1] * q[2]) /    //            (q[3] * q[3] - q[0] * q[0] - q[1] * q[1] + q[2] * q[2]));    //printf("%5.3f %+6.1f %+6.1f %+6.1f\n",    //       ntime, e[0] * 180 / M_PI, e[1] * 180 / M_PI, e[2] * 180 / M_PI);    // Construct data packet    data.xpos = 0;    data.ypos = 0;    data.yaw = htonl((int32_t) (-e[2] * 180 / M_PI));    data.xspeed = 0;    data.yspeed = 0;    data.yawspeed = 0;    data.stall = 0;    // HACK get the time     GlobalTime->GetTime(&time);    // Make data available    PutData(&data, sizeof(data), time.tv_sec, time.tv_usec);    /*    // TESTING    GetStabV(&ntime, al, vr);    //printf("%+f %+f %+f\n", al[0], al[1], al[2]);    if (time > 0)    {      // Integrate      dt = ntime - time;      pl[0] += vl[0] * dt + 0.5 * al[0] * dt * dt;      pl[1] += vl[1] * dt + 0.5 * al[1] * dt * dt;      vl[0] += al[0] * dt;      vl[1] += al[1] * dt;            pr[2] += vr[2] * dt;    }    printf("%5.3f %+6.3f %+6.3f %+6.3f\n",           dt, pl[0], pl[1], pr[2] * 180 / M_PI);    */  }  return;}////////////////////////////////////////////////////////////////////////////////// Open the terminal// Returns 0 on successint MicroStrain3DMG::OpenPort(){  char firmware[32];    // Open the port  this->fd = open(this->port_name, O_RDWR | O_SYNC , S_IRUSR | S_IWUSR );  if (this->fd < 0)  {    PLAYER_ERROR2("unable to open serial port [%s]; [%s]",                  (char*) this->port_name, strerror(errno));    return -1;  }  // Change port settings  struct termios term;  if (tcgetattr(this->fd, &term) < 0)  {    PLAYER_ERROR("Unable to get serial port attributes");    return -1;  }#if HAVE_CFMAKERAW  cfmakeraw( &term );#endif  cfsetispeed(&term, B38400);  cfsetospeed(&term, B38400);  if (tcsetattr(this->fd, TCSAFLUSH, &term) < 0 )  {    PLAYER_ERROR("Unable to set serial port attributes");    return -1;  }  // Make sure queues are empty before we begin  tcflush(this->fd, TCIOFLUSH);  printf("getting version...\n");    // Check the firmware version  if (GetFirmware(firmware, sizeof(firmware)) < 0)    return -1;  printf("opened %s\n", firmware);      return 0;}////////////////////////////////////////////////////////////////////////////////// Close the serial port// Returns 0 on successint MicroStrain3DMG::ClosePort(){  close(this->fd);  return 0;}////////////////////////////////////////////////////////////////////////////////// Read the firmware versionint MicroStrain3DMG::GetFirmware(char *firmware, int len){  int version;  uint8_t cmd[1];  uint8_t rep[5];    cmd[0] = CMD_VERSION;  if (Transact(cmd, sizeof(cmd), rep, sizeof(rep)) < 0)    return -1;  version = MAKEUINT16(rep[2], rep[1]);    snprintf(firmware, len, "3DM-G Firmware %d.%d.%02d",           version / 1000, (version % 1000) / 100, version % 100);  return 0;}////////////////////////////////////////////////////////////////////////////////// Read the stabilized accelertion vectorsint MicroStrain3DMG::GetStabV(double *time, double v[3], double w[3]){  int i, k;  uint8_t cmd[1];  uint8_t rep[23];  int ticks;    cmd[0] = CMD_STABV;  if (Transact(cmd, sizeof(cmd), rep, sizeof(rep)) < 0)    return -1;  for (i = 0; i < 3; i++)  {    k = 7 + 2 * i;    v[i] = (double) ((int16_t) MAKEUINT16(rep[k + 1], rep[k])) / 8192 * G;    k = 13 + 2 * i;    w[i] = (double) ((int16_t) MAKEUINT16(rep[k + 1], rep[k])) / (64 * 8192 * TICK_TIME);  }  // TODO: handle rollover  ticks = (uint16_t) MAKEUINT16(rep[20], rep[19]);  *time = ticks * TICK_TIME;  return 0;}////////////////////////////////////////////////////////////////////////////////// Read the stabilized orientation matrixint MicroStrain3DMG::GetStabM(int M[3][3]){  int i, j, k;  uint8_t cmd[1];  uint8_t rep[23];    cmd[0] = CMD_STABM;  if (Transact(cmd, sizeof(cmd), rep, sizeof(rep)) < 0)    return -1;  // Read the orientation matrix  k = 1;  for (i = 0; i < 3; i++)  {    for (j = 0; j < 3; j++)    {      M[j][i] = (int) ((int16_t) MAKEUINT16(rep[k + 1], rep[k]));      k += 2;      printf("%+6d ", M[j][i]);    }    printf("\n");  }    return 0;}////////////////////////////////////////////////////////////////////////////////// Read the stabilized orientation quaternionint MicroStrain3DMG::GetStabQ(double *time, double q[4]){  int i, k;  int ticks;  uint8_t cmd[1];  uint8_t rep[13];    cmd[0] = CMD_STABQ;  if (Transact(cmd, sizeof(cmd), rep, sizeof(rep)) < 0)    return -1;  // Read the quaternion  k = 1;  for (i = 0; i < 4; i++)  {    q[i] = (double) ((int16_t) MAKEUINT16(rep[k + 1], rep[k])) / 8192;    k += 2;  }  // TODO: handle rollover  ticks = (uint16_t) MAKEUINT16(rep[10], rep[9]);  *time = ticks * TICK_TIME;      return 0;}////////////////////////////////////////////////////////////////////////////////// Send a packet and wait for a reply from the IMU.// Returns the number of bytes read.int MicroStrain3DMG::Transact(void *cmd, int cmd_len, void *rep, int rep_len){  int nbytes, bytes;    // Make sure both input and output queues are empty  tcflush(this->fd, TCIOFLUSH);      // Write the data to the port  bytes = write(this->fd, cmd, cmd_len);  if (bytes < 0)    PLAYER_ERROR1("error writing to IMU [%s]", strerror(errno));  assert(bytes == cmd_len);  // Make sure the queue is drained  // Synchronous IO doesnt always work  tcdrain(this->fd);  // Read data from the port  bytes = 0;  while (bytes < rep_len)  {    nbytes = read(this->fd, (char*) rep + bytes, rep_len - bytes);    if (nbytes < 0)      PLAYER_ERROR1("error reading from IMU [%s]", strerror(errno));    bytes += nbytes;  }    return bytes;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费观看高清在线观看| 9久草视频在线视频精品| 日韩电影在线免费看| 亚洲综合网站在线观看| 亚洲激情av在线| 亚洲一区二区三区四区的| 亚洲一区二区3| 亚洲综合区在线| 亚洲成年人网站在线观看| 无吗不卡中文字幕| 人人精品人人爱| 久久99在线观看| 国产精品一区久久久久| 国产精品一区二区三区99| 九色综合国产一区二区三区| 国产一区二区三区免费播放| 国产精品一区二区91| 成人黄色在线视频| 日本精品视频一区二区| 欧美亚一区二区| 91精品欧美福利在线观看| 精品日韩在线观看| 中文字幕精品一区二区三区精品| 国产欧美日韩视频一区二区| 亚洲私人黄色宅男| 日韩制服丝袜先锋影音| 久久国产乱子精品免费女| 国产成人综合网| 91美女视频网站| 欧美日韩国产高清一区二区三区| 日韩欧美一区二区三区在线| 国产视频一区二区三区在线观看| 国产精品久久久久久久久晋中 | 精品日本一线二线三线不卡| 久久久蜜桃精品| 亚洲精品videosex极品| 美女视频黄频大全不卡视频在线播放| 国内精品免费在线观看| 99视频精品在线| 欧美一区二区三区思思人| 国产欧美中文在线| 亚洲一二三区视频在线观看| 精品一区二区免费| 91小视频在线观看| 日韩你懂的在线播放| 中文字幕视频一区| 麻豆精品一区二区av白丝在线| 国产成人av一区二区| 欧美日韩一区二区不卡| 久久色成人在线| 亚洲成人av在线电影| 国产成a人亚洲| 欧美日韩亚洲不卡| 国产精品欧美极品| 麻豆专区一区二区三区四区五区| 99精品国产91久久久久久 | 国产精品国产三级国产aⅴ无密码| 亚洲五月六月丁香激情| 国产精品系列在线观看| 欧美久久一区二区| 亚洲色图欧美激情| 国产一区二区三区四区五区美女 | 久久亚洲一级片| 亚洲影视在线播放| 成人在线视频一区二区| 91超碰这里只有精品国产| 欧美国产日产图区| 老司机精品视频在线| 欧美性生活久久| 中文字幕日本不卡| 国产精品69毛片高清亚洲| 91精品婷婷国产综合久久性色 | heyzo一本久久综合| 日韩久久精品一区| 亚洲成av人片一区二区| 91影院在线免费观看| 久久久777精品电影网影网 | 成人国产一区二区三区精品| 日韩欧美国产三级电影视频| 亚洲午夜日本在线观看| 91小视频免费观看| 国产精品女同一区二区三区| 国产一区二区视频在线播放| 日韩午夜在线观看视频| 亚洲成av人片观看| 欧美亚一区二区| 亚洲欧美日韩久久| 大尺度一区二区| 欧美精品一区二区久久婷婷| 日韩国产精品久久久久久亚洲| 91美女在线看| 国产精品国产精品国产专区不片| 国产剧情在线观看一区二区| 精品国产乱码久久久久久图片| 水野朝阳av一区二区三区| 在线观看一区不卡| 亚洲欧美视频在线观看| 91免费观看视频在线| 亚洲人成网站在线| 99国产欧美另类久久久精品| 国产精品久久久久影院亚瑟 | 久久亚洲精华国产精华液| 美女性感视频久久| 日韩小视频在线观看专区| 视频一区在线播放| 欧美一区二区三区日韩| 奇米影视在线99精品| 91精品国产综合久久国产大片| 日韩中文字幕区一区有砖一区| 欧美日韩aaaaaa| 日韩国产欧美三级| 日韩精品中午字幕| 国产精品系列在线播放| 日本一区二区三区电影| 成人一级视频在线观看| 国产精品的网站| 色婷婷精品大在线视频| 亚洲第一电影网| 日韩一二三区视频| 国产一区不卡精品| 国产精品久久久久久久久免费相片 | 亚洲一区二三区| 制服丝袜亚洲网站| 国产一区二区在线视频| 亚洲国产高清在线| 91小视频在线免费看| 五月婷婷久久丁香| 日韩欧美国产精品一区| 国产精品一区二区果冻传媒| 国产精品免费久久久久| 91黄色激情网站| 日韩福利电影在线观看| 久久久久久久综合色一本| 波多野结衣精品在线| 亚洲v日本v欧美v久久精品| 日韩欧美亚洲另类制服综合在线| 国产精品综合av一区二区国产馆| 国产精品高清亚洲| 欧美日韩午夜精品| 国产乱子伦视频一区二区三区| 亚洲天堂网中文字| 欧美剧在线免费观看网站| 国产美女精品在线| 亚洲激情一二三区| 欧美mv日韩mv国产| 色狠狠av一区二区三区| 久久激情五月激情| 最新国产精品久久精品| 3atv一区二区三区| 成人黄色免费短视频| 日本视频一区二区三区| 欧美高清在线视频| 欧美日韩的一区二区| 成人听书哪个软件好| 午夜久久电影网| 国产精品视频观看| 欧美一区二区三区思思人| av一区二区三区黑人| 蜜桃av一区二区三区| 亚洲免费在线观看| 久久综合一区二区| 欧美情侣在线播放| 不卡视频一二三| 老鸭窝一区二区久久精品| 亚洲男女毛片无遮挡| 26uuu国产在线精品一区二区| 在线观看一区二区视频| 国产宾馆实践打屁股91| 日本亚洲三级在线| 一区二区三区四区中文字幕| 久久久久久9999| 日韩一区二区免费高清| 色欧美日韩亚洲| 成人午夜视频免费看| 久久精品av麻豆的观看方式| 亚洲激情在线激情| 欧美国产欧美综合| 精品久久五月天| 欧美久久婷婷综合色| 在线一区二区视频| www.日韩在线| 福利一区在线观看| 国产一区二区免费在线| 日韩 欧美一区二区三区| 一区二区三区高清在线| 国产精品萝li| 国产午夜亚洲精品不卡| 欧美成人a视频| 91精品国产高清一区二区三区蜜臀| 在线观看亚洲精品| 91成人在线免费观看| 99视频一区二区| a在线欧美一区| 成人精品免费看| 国产成人免费xxxxxxxx| 精品亚洲成a人在线观看 | 欧美午夜寂寞影院| 色偷偷久久一区二区三区| 99久久亚洲一区二区三区青草| 粉嫩久久99精品久久久久久夜|