gazeboclient.cc
来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· CC 代码 · 共 89 行
CC
89 行
/* * Gazebo - Outdoor Multi-Robot Simulator * Copyright (C) 2003 * Nate Koenig & 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: Gazebo (simulator) client functions * Author: Nate Koenig, Andrew Howard * Date: 2 March 2006 * CVS: $Id: GazeboClient.cc,v 1.1 2006/03/02 22:26:31 natepak Exp $ */#include <assert.h>#include <stdio.h>#include <libplayercore/playercore.h>#include "GazeboTime.hh"#include "GazeboClient.hh"gz_client_t *GazeboClient::client = NULL;gz_sim_t *GazeboClient::sim = NULL;const char *GazeboClient::prefixId = "";extern PlayerTime* GlobalTime;////////////////////////////////////////////////////////////////////////////////// Initialize int GazeboClient::Init(int serverid, const char *prefixid){ if (prefixid != NULL) GazeboClient::prefixId = prefixid; GazeboClient::client = gz_client_alloc(); assert(GazeboClient::client); // Use version 0.5.0 if (gz_client_connect_wait(GazeboClient::client, serverid, GZ_CLIENT_ID_PLAYER) != 0) return -1; GazeboClient::sim = gz_sim_alloc(); assert(GazeboClient::sim); if (gz_sim_open(GazeboClient::sim, GazeboClient::client, "default") != 0) { printf("Gazeob Error: Unable to connect to the Gazebo Sim Interface\n"); return -1; } // steal the global clock - a bit aggressive, but a simple approach if (GlobalTime) delete GlobalTime; assert((GlobalTime = new GazeboTime())); return 0;}////////////////////////////////////////////////////////////////////////////////// Finalizeint GazeboClient::Fini(){ gz_sim_close(GazeboClient::sim); gz_sim_free(GazeboClient::sim); GazeboClient::sim = NULL; if (gz_client_disconnect(GazeboClient::client) != 0) return -1; gz_client_free(GazeboClient::client); GazeboClient::client = NULL; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?