playersd.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2007
4  * Brian Gerkey
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 /*
23  * Player - One Hell of a Robot Server
24  * Copyright (C) 2007
25  * Brian Gerkey
26  *
27  *
28  * This library is free software; you can redistribute it and/or
29  * modify it under the terms of the GNU Lesser General Public
30  * License as published by the Free Software Foundation; either
31  * version 2.1 of the License, or (at your option) any later version.
32  *
33  * This library is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36  * Lesser General Public License for more details.
37  *
38  * You should have received a copy of the GNU Lesser General Public
39  * License along with this library; if not, write to the Free Software
40  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
41  */
42 
43 /*
44  * Interface to libplayersd
45  *
46  * $Id$
47  */
48 
58 #ifndef _PLAYER_SD_H
59 #define _PLAYER_SD_H
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #include <libplayerinterface/player.h>
66 
67 #define PLAYER_SD_SERVICENAME "_player31._tcp"
68 #define PLAYER_SD_DEVICE_TXTNAME "device"
69 #define PLAYER_SD_NAME_MAXLEN 256
70 #define PLAYER_SD_TXT_MAXLEN 256
71 
73 typedef struct player_sd_dev
74 {
75  // Is this entry valid?
76  uint8_t valid;
77  // Name of the device
78  char name[PLAYER_SD_NAME_MAXLEN];
79  // Is the address valid?
80  uint8_t addr_valid;
81  // Did address resolution fail?
82  uint8_t addr_fail;
83  // Player address components
84  char hostname[PLAYER_SD_NAME_MAXLEN];
85  uint32_t robot;
86  uint16_t interf;
87  uint16_t index;
89 
91 typedef struct player_sd
92 {
95  void* sdRef;
99  size_t devs_len;
101 
105 
108 
111 
114 
118  const char* name,
119  player_devaddr_t addr);
120 
124  const char* name);
125 
129  player_sd_dev_t* dev);
130 
144  double timeout,
145  int keepalive,
147 
157 int player_sd_update(player_sd_t* sd, double timeout);
158 
161 
163 // Common functions, implemented in playersd.c
164 
168 
185  player_sd_dev_t* result,
186  size_t result_len,
187  const char* name,
188  const char* hostname,
189  int robot,
190  int interf,
191  int index);
192 
196 
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
206 #endif
void(* player_sd_browse_callback_fn_t)(player_sd_t *sd, player_sd_dev_t *dev)
Prototype for a callback function that can be invoked when devices are added or removed.
Definition: playersd.h:128
The PlannerProxy proxy provides an interface to a 2D motion interface_planner.
Definition: playerc++.h:1721
#define PLAYERC_TRANSPORT_TCP
The valid transports.
Definition: playerc.h:114
The ImuProxy class is used to control an interface_imu device.
Definition: playerc++.h:1118
player_sd_t * player_sd_init(void)
Initialize service discovery, passing back a pointer that will be passed into all future calls.
The Position2dProxy class is used to control a interface_position2d device.
Definition: playerc++.h:2029
The C++ exception class.
Definition: playererror.h:67
The SimulationProxy proxy provides access to a interface_simulation device.
Definition: playerc++.h:2556
void Close()
Command the gripper to close.
int player_sd_browse(player_sd_t *sd, double timeout, int keepalive, player_sd_browse_callback_fn_t cb)
Browse for player devices.
int player_sd_unregister(player_sd_t *sd, const char *name)
Unregister (terminate) the named device.
A pose in the plane.
Definition: player.h:218
int player_sd_register(player_sd_t *sd, const char *name, player_devaddr_t addr)
Register the named device.
A device, represented by its name and address.
Definition: playersd.h:74
struct player_sd player_sd_t
Service discovery object.
player_sd_dev_t * devs
List of devices discovered by browsing.
Definition: playersd.h:97
The LogProxy proxy provides access to a interface_log device.
Definition: playerc++.h:1576
The BumperProxy class is used to read from a interface_bumper device.
Definition: playerc++.h:477
Service discovery object.
Definition: playersd.h:92
double px
X [m].
Definition: player.h:220
The SpeechProxy class is used to control a interface_speech device.
Definition: playerc++.h:2651
player_sd_dev_t * _player_sd_add_device(player_sd_t *sd, const char *name)
Add a device to the local cache.
double py
Y [m].
Definition: player.h:222
The PowerProxy class controls a interface_power device.
Definition: playerc++.h:2337
const int PLAYER_PORTNUM
The default port number for PlayerClient.
Definition: utility.h:61
void player_sd_unlock(player_sd_t *sd)
Unlock access to playersd structures, such as the local device cache.
int player_sd_find_devices(player_sd_t *sd, player_sd_dev_t *result, size_t result_len, const char *name, const char *hostname, int robot, int interf, int index)
Find a device in the local cache that matches the given criteria.
The LaserProxy class is used to control a interface_laser device.
Definition: playerc++.h:1225
The AioProxy class is used to read from a interface_aio (analog I/O) device.
Definition: playerc++.h:210
The RangerProxy class is used to control a interface_ranger device.
Definition: playerc++.h:2424
The WiFiProxy class controls a interface_wifi device.
Definition: playerc++.h:2910
PLAYERC_EXPORT int playerc_planner_get_waypoints(playerc_planner_t *device)
Get the list of waypoints.
The DioProxy class is used to read from a interface_dio (digital I/O) device.
Definition: playerc++.h:766
The SonarProxy class is used to control a interface_sonar device.
Definition: playerc++.h:2603
void player_sd_printcache(player_sd_t *sd)
Print the contents of the local device cache to the console.
The client proxy base class.
Definition: clientproxy.h:80
struct player_sd_dev player_sd_dev_t
A device, represented by its name and address.
The Position1dProxy class is used to control a interface_position1d device.
Definition: playerc++.h:1905
void * sdRef
Opaque pointer to underlying zeroconf client object.
Definition: playersd.h:95
The CameraProxy class can be used to get images from a interface_camera device.
Definition: playerc++.h:527
void player_sd_fini(player_sd_t *sd)
Finalize service discovery, freeing associated resources.
The GpsProxy class is used to control a interface_gps device.
Definition: playerc++.h:855
A device address.
Definition: player.h:146
PLAYERC_EXPORT int playerc_localize_get_particles(playerc_localize_t *device)
Request the particle set.
The GripperProxy class is used to control a interface_gripper device.
Definition: playerc++.h:1005
#define PLAYER_SD_NAME_MAXLEN
A device, represented by its name and address.
Definition: playersd.h:69
The ActArrayProxy class is used to control a interface_actarray device.
Definition: playerc++.h:142
The BlobfinderProxy class is used to control a interface_blobfinder device.
Definition: playerc++.h:426
The PlayerClient is used for communicating with the player server.
Definition: playerclient.h:121
int player_sd_update(player_sd_t *sd, double timeout)
Check for new device updates, waiting for timeout s.
The OpaqueProxy proxy provides an interface to a generic interface_opaque.
Definition: playerc++.h:1681
The LocalizeProxy class is used to control a interface_localize device, which can provide multiple po...
Definition: playerc++.h:1502
The VectorMapProxy class is used to interface to a vectormap.
Definition: playerc++.h:2866
player_sd_dev_t * player_sd_get_device(player_sd_t *sd, const char *name)
Look up a device by name.
The map proxy provides access to a interface_map device.
Definition: playerc++.h:1623
The Position3dProxy class is used to control a interface_position3d device.
Definition: playerc++.h:2196
PLAYERC_EXPORT int playerc_map_get_map(playerc_map_t *device)
Get the map, which is stored in the proxy.
size_t devs_len
Number of devices discovered.
Definition: playersd.h:99
double pa
yaw [rad]
Definition: player.h:224
The FiducialProxy class is used to control interface_fiducial devices.
Definition: playerc++.h:807
void MoveTo(uint32_t aJoint, float aPos)
Send an actuator to a position.
The IrProxy class is used to control an interface_ir device.
Definition: playerc++.h:1176
void player_sd_lock(player_sd_t *sd)
Lock access to playersd structures, such as the local device cache.
int player_sd_browse_stop(player_sd_t *sd)
Stop browsing. Returns 0 on success, non-zero on error.
The PtzProxy class is used to control a interface_ptz device.
Definition: playerc++.h:2378
void Open()
Command the gripper to open.
const std::string PLAYER_HOSTNAME
The default hostname for PlayerClient.
Definition: utility.h:63
The LimbProxy class is used to control a interface_limb device.
Definition: playerc++.h:1398