gz_position.c

来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· C语言 代码 · 共 120 行

C
120
字号
/* *  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: Position interface * Author: Andrew Howard * Date: 21 Apr 2003 * CVS: $Id: gz_position.c,v 1.8 2004/11/10 08:21:44 inspectorg Exp $ */#include <string.h>#include <stdlib.h>#include <stdio.h>#include "gazebo.h"// Create an interfacegz_position_t *gz_position_alloc(){  gz_position_t *self;  self = calloc(1, sizeof(gz_position_t));  self->iface = gz_iface_alloc();  return self;}// Destroy an interfacevoid gz_position_free(gz_position_t *self){  gz_iface_free(self->iface);  free(self);  return;}// Create the interfaceint gz_position_create(gz_position_t *self, gz_server_t *server, const char *id,                       const char *model_type, int model_id, int parent_model_id){  if (gz_iface_create(self->iface, server, "position", id, sizeof(gz_position_data_t)) != 0)    return -1;  self->data = self->iface->mmap;  strncpy(self->data->head.model_type, model_type, sizeof(self->data->head.model_type));  self->data->head.model_id = (int) model_id;  self->data->head.parent_model_id = (int) parent_model_id;  return 0;}// Destroy the interface (server)int gz_position_destroy(gz_position_t *self){  self->data = NULL;  return gz_iface_destroy(self->iface);}// Open an existing interfaceint gz_position_open(gz_position_t *self, gz_client_t *client, const char *id){  if (gz_iface_open(self->iface, client, "position", id, sizeof(gz_position_data_t)) != 0)    return -1;  self->data = self->iface->mmap;  return 0;}  // Close the interfaceint gz_position_close(gz_position_t *self){  self->data = NULL;  return gz_iface_close(self->iface);}// Lock the interface.int gz_position_lock(gz_position_t *self, int blocking){  return gz_iface_lock(self->iface, blocking);}// Unlock the interfacevoid gz_position_unlock(gz_position_t *self){  return gz_iface_unlock(self->iface);}// Tell clients that new data is availableint gz_position_post(gz_position_t *self){  return gz_iface_post(self->iface);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?