Update of /cvsroot/playerstage/code/player/server/drivers/ptz
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4552/server/drivers/ptz
Modified Files:
Tag: release-2-0-patches
amtecpowercube.cc canonvcc4.cc
Log Message:
backported lots of stuff from HEAD
Index: canonvcc4.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/server/drivers/ptz/canonvcc4.cc,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** canonvcc4.cc 23 Feb 2006 18:54:55 -0000 1.9
--- canonvcc4.cc 7 Jun 2006 16:12:53 -0000 1.9.2.1
***************
*** 26,32 ****
* @brief Canon VC-C4 pan-tilt-zoom camera
- @todo This driver is currently disabled because it needs to be updated to
- the Player 2.0 API.
-
The canonvcc4 driver controls a Canon VC-C4 PTZ camera.
--- 26,29 ----
***************
*** 111,118 ****
#include <math.h>
! #include "replace.h" /* for poll(2) and cfmakeraw(3) */
! #include "driver.h"
! #include "drivertable.h"
! #include "player.h"
--- 108,113 ----
#include <math.h>
! #include <libplayercore/playercore.h>
! #include <replace/replace.h>
***************
*** 184,189 ****
int pandemand , tiltdemand , zoomdemand ;
! // MessageHandler
! int ProcessMessage(ClientData * client, player_msghdr * hdr, uint8_t *
data, uint8_t * resp_data, int * resp_len);
virtual int Setup();
--- 179,184 ----
int pandemand , tiltdemand , zoomdemand ;
! // MessageHandler
! int ProcessMessage(MessageQueue* resp_queue, player_msghdr * hdr, void *
data);
virtual int Setup();
***************
*** 210,214 ****
canonvcc4::canonvcc4(ConfigFile* cf, int section)
! : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_PTZ_CODE,
PLAYER_ALL_MODE)
{
pandemand = 0; tiltdemand = 0; zoomdemand = 0;
--- 205,209 ----
canonvcc4::canonvcc4(ConfigFile* cf, int section)
! : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,
PLAYER_PTZ_CODE)
{
pandemand = 0; tiltdemand = 0; zoomdemand = 0;
***************
*** 329,342 ****
puts("Done.");
! // zero the command and data buffers
! /*player_ptz_data_t data;
! player_ptz_cmd_t cmd;
!
! data.pan = data.tilt = data.zoom = 0;
! cmd.pan = cmd.tilt = cmd.zoom = 0;
!
! PutData((void*)&data,sizeof(data),NULL);
! PutCommand(this->device_id,(void*)&cmd,sizeof(cmd),NULL);*/
!
//request_state = IDLE;
// start the thread to talk with the camera
--- 324,328 ----
puts("Done.");
!
//request_state = IDLE;
// start the thread to talk with the camera
***************
*** 921,937 ****
int err;
! if(pandemand != (short)ntohs((unsigned short)(command.pan)))
{
! pandemand = (short)ntohs((unsigned short)(command.pan));
newpantilt = true;
}
! if(tiltdemand != (short)ntohs((unsigned short)(command.tilt)))
{
! tiltdemand = (short)ntohs((unsigned short)(command.tilt));
newpantilt = true;
}
! if(zoomdemand != (short)ntohs((unsigned short)(command.zoom)))
{
! zoomdemand = (short) ntohs((unsigned short)(command.zoom));
newzoom = true;
}
--- 907,923 ----
int err;
! if(pandemand != (short)((unsigned short)(command.pan)))
{
! pandemand = (short)((unsigned short)(command.pan));
newpantilt = true;
}
! if(tiltdemand != (short)((unsigned short)(command.tilt)))
{
! tiltdemand = (short)((unsigned short)(command.tilt));
newpantilt = true;
}
! if(zoomdemand != (short)((unsigned short)(command.zoom)))
{
! zoomdemand = (short) ((unsigned short)(command.zoom));
newzoom = true;
}
***************
*** 1004,1014 ****
// Copy the data.
! data.pan = htons((unsigned short)pan);
! data.tilt = htons((unsigned short)tilt);
! data.zoom = htons((unsigned short)zoom);
/* test if we are supposed to cancel */
pthread_testcancel();
! PutMsg(device_id,NULL,PLAYER_MSGTYPE_DATA,0,(void*)&data,
sizeof(player_ptz_data_t),NULL);
--- 990,1000 ----
// Copy the data.
! data.pan = ((unsigned short)pan);
! data.tilt = ((unsigned short)tilt);
! data.zoom = ((unsigned short)zoom);
/* test if we are supposed to cancel */
pthread_testcancel();
!
Publish(device_addr,NULL,PLAYER_MSGTYPE_DATA,PLAYER_PTZ_DATA_STATE,(void*)&data,
sizeof(player_ptz_data_t),NULL);
***************
*** 1017,1036 ****
}
! int canonvcc4::ProcessMessage(ClientData * client, player_msghdr * hdr,
uint8_t * data, uint8_t * resp_data, int * resp_len)
{
! assert(hdr);
! assert(data);
! assert(resp_data);
! assert(resp_len);
! if (MatchMessage(hdr, PLAYER_MSGTYPE_CMD, 0, device_id))
{
assert(hdr->size == sizeof(player_ptz_cmd_t));
ProcessCommand(*reinterpret_cast<player_ptz_cmd_t *> (data));
- *resp_len = 0;
return 0;
}
- *resp_len = 0;
return -1;
}
--- 1003,1018 ----
}
! int canonvcc4::ProcessMessage(MessageQueue * resp_queue, player_msghdr * hdr,
void * data)
{
! assert(hdr);
! assert(data);
! if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
PLAYER_PTZ_CMD_STATE, device_addr))
{
assert(hdr->size == sizeof(player_ptz_cmd_t));
ProcessCommand(*reinterpret_cast<player_ptz_cmd_t *> (data));
return 0;
}
return -1;
}
Index: amtecpowercube.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/server/drivers/ptz/amtecpowercube.cc,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -C2 -d -r1.17 -r1.17.2.1
*** amtecpowercube.cc 23 Feb 2006 21:22:16 -0000 1.17
--- amtecpowercube.cc 7 Jun 2006 16:12:53 -0000 1.17.2.1
***************
*** 28,34 ****
* @brief Amtec PowerCube pan-tilt unit
- @todo This driver is currently disabled because it needs to be updated to
- the Player 2.0 API.
-
The amtecpowercube driver controls the Amtec PowerCube Wrist,
a powerful pan-tilt unit that can, for example, carry a SICK laser
--- 28,31 ----
***************
*** 107,115 ****
#include <math.h>
! #include "driver.h"
! #include "error.h"
! #include "drivertable.h"
! #include "player.h"
! #include "replace.h"
#define AMTEC_DEFAULT_PORT "/dev/ttyS0"
--- 104,109 ----
#include <math.h>
! #include <libplayercore/playercore.h>
!
#define AMTEC_DEFAULT_PORT "/dev/ttyS0"
***************
*** 219,223 ****
// MessageHandler
! int ProcessMessage(ClientData * client, player_msghdr * hdr, uint8_t *
data, uint8_t * resp_data, int * resp_len);
virtual int Setup();
--- 213,217 ----
// MessageHandler
! int ProcessMessage(MessageQueue* resp_queue, player_msghdr * hdr, void *
data);
virtual int Setup();
***************
*** 239,243 ****
AmtecPowerCube::AmtecPowerCube( ConfigFile* cf, int section)
! : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_PTZ_CODE,
PLAYER_ALL_MODE)
{
fd = -1;
--- 233,237 ----
AmtecPowerCube::AmtecPowerCube( ConfigFile* cf, int section)
! : Driver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,
PLAYER_PTZ_CODE)
{
fd = -1;
***************
*** 1004,1015 ****
}
! int AmtecPowerCube::ProcessMessage(ClientData * client, player_msghdr * hdr,
uint8_t * data, uint8_t * resp_data, int * resp_len)
{
! assert(hdr);
! assert(data);
! assert(resp_data);
! assert(resp_len);
! if (MatchMessage(hdr, PLAYER_MSGTYPE_CMD, 0, device_id))
{
short newpan, newtilt;
--- 998,1008 ----
}
!
! int AmtecPowerCube::ProcessMessage(MessageQueue * resp_queue, player_msghdr *
hdr, void * data)
{
! assert(hdr);
! assert(data);
! if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_CMD,
PLAYER_PTZ_CMD_STATE, device_addr))
{
short newpan, newtilt;
***************
*** 1022,1027 ****
{
// reverse pan angle, to increase ccw
! newpan = -(short)ntohs(command.pan);
! newtilt = (short)ntohs(command.tilt);
if(newpan != lastpan)
--- 1015,1020 ----
{
// reverse pan angle, to increase ccw
! newpan = -(short)(command.pan);
! newtilt = (short)(command.tilt);
if(newpan != lastpan)
***************
*** 1052,1057 ****
{
// reverse pan angle, to increase ccw
! newpanspeed = -(short)ntohs(command.panspeed);
! newtiltspeed = (short)ntohs(command.tiltspeed);
if(newpanspeed != lastpanspeed)
--- 1045,1050 ----
{
// reverse pan angle, to increase ccw
! newpanspeed = -(short)(command.panspeed);
! newtiltspeed = (short)(command.tiltspeed);
if(newpanspeed != lastpanspeed)
***************
*** 1085,1096 ****
}
- *resp_len = 0;
return 0;
}
! if (MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_PTZ_CONTROL_MODE,
device_id))
{
! assert(hdr->size == sizeof(player_ptz_controlmode_config));
! player_ptz_controlmode_config * cfg =
reinterpret_cast<player_ptz_controlmode_config *> (data);
if((cfg->mode != PLAYER_PTZ_VELOCITY_CONTROL) &&
--- 1078,1087 ----
}
return 0;
}
! if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
PLAYER_PTZ_REQ_CONTROL_MODE, device_addr))
{
! player_ptz_req_control_mode_t * cfg =
reinterpret_cast<player_ptz_req_control_mode_t *> (data);
if((cfg->mode != PLAYER_PTZ_VELOCITY_CONTROL) &&
***************
*** 1098,1113 ****
{
PLAYER_WARN1("unknown control mode requested: %d", cfg->mode);
! *resp_len = 0;
! return PLAYER_MSGTYPE_RESP_NACK;
}
else
{
controlmode = cfg->mode;
! *resp_len = 0;
! return PLAYER_MSGTYPE_RESP_ACK;
}
}
- *resp_len = 0;
return -1;
}
--- 1089,1104 ----
{
PLAYER_WARN1("unknown control mode requested: %d", cfg->mode);
! Publish(device_addr, resp_queue, PLAYER_MSGTYPE_RESP_NACK,
PLAYER_PTZ_REQ_CONTROL_MODE);
!
! return 0;
}
else
{
controlmode = cfg->mode;
! Publish(device_addr, resp_queue, PLAYER_MSGTYPE_RESP_ACK,
PLAYER_PTZ_REQ_CONTROL_MODE);
! return 0;
}
}
return -1;
}
***************
*** 1155,1165 ****
}
! data.pan = htons(currpan);
! data.tilt = htons(currtilt);
data.zoom = 0;
! data.panspeed = htons(currpanspeed);
! data.tiltspeed = htons(currtiltspeed);
! PutMsg(device_id, NULL, PLAYER_MSGTYPE_DATA, 0, (unsigned char*)&data,
sizeof(player_ptz_data_t),NULL);
// get the module state (for debugging and warning)
--- 1146,1156 ----
}
! data.pan = (currpan);
! data.tilt = (currtilt);
data.zoom = 0;
! data.panspeed = (currpanspeed);
! data.tiltspeed = (currtiltspeed);
! Publish(device_addr, NULL, PLAYER_MSGTYPE_DATA, PLAYER_PTZ_DATA_STATE,
(unsigned char*)&data, sizeof(player_ptz_data_t),NULL);
// get the module state (for debugging and warning)
***************
*** 1182,1229 ****
}
}
- /*
- void
- AmtecPowerCube::HandleConfig(void *client, unsigned char *buf, size_t len)
- {
- player_ptz_controlmode_config* cfg;
- player_ptz_cmd_t cmd;
-
- switch(buf[0])
- {
- case PLAYER_PTZ_CONTROL_MODE_REQ:
- cfg = (player_ptz_controlmode_config*)buf;
- if(len != sizeof(player_ptz_controlmode_config))
- {
- PLAYER_WARN("control mode request is wrong size; ignoring");
- if (PutReply(client, PLAYER_MSGTYPE_RESP_NACK,NULL))
- PLAYER_ERROR("Failed to PutReply\n");
- }
- else
- {
- if((cfg->mode != PLAYER_PTZ_VELOCITY_CONTROL) &&
- (cfg->mode != PLAYER_PTZ_POSITION_CONTROL))
- {
- PLAYER_WARN1("unknown control mode requested: %d", cfg->mode);
- if(PutReply(client, PLAYER_MSGTYPE_RESP_NACK,NULL))
- PLAYER_ERROR("Failed to PutReply\n");
- }
- else
- {
- // change mode, and zero existing commands, to avoid unexpected
- // consequences.
- controlmode = cfg->mode;
- memset(&cmd,0,sizeof(cmd));
- PutCommand(this->device_id,(unsigned char*)&cmd,sizeof(cmd),NULL);
- if (PutReply(client, PLAYER_MSGTYPE_RESP_ACK,NULL))
- PLAYER_ERROR("Failed to PutReply\n");
- }
- }
- break;
- default:
- PLAYER_WARN1("unknown config request: %d", buf[0]);
- if (PutReply(client, PLAYER_MSGTYPE_RESP_NACK,NULL))
- PLAYER_ERROR("Failed to PutReply\n");
- break;
- }
- }
- */
--- 1173,1174 ----
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit