Public Member Functions | |
mbasedriver (ConfigFile *cf, int section) | |
virtual int | Subscribe (player_devaddr_t id) |
Subscribe. More... | |
virtual int | Unsubscribe (player_devaddr_t id) |
Unsubscribe. | |
virtual void | Main () |
Main. More... | |
virtual int | Setup () |
Setup. More... | |
virtual int | Shutdown () |
Shutdown. More... | |
virtual int | ProcessMessage (QueuePointer &resp_queue, player_msghdr *hdr, void *data) |
ProcessMessage. More... | |
Public Member Functions inherited from Driver | |
bool | HasSubscriptions () |
virtual void | Publish (player_devaddr_t addr, QueuePointer &queue, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true) |
Publish a message via one of this driver's interfaces. More... | |
virtual void | Publish (player_devaddr_t addr, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true) |
Publish a message via one of this driver's interfaces. More... | |
virtual void | Publish (QueuePointer &queue, player_msghdr_t *hdr, void *src, bool copy=true) |
Publish a message via one of this driver's interfaces. More... | |
virtual void | Publish (player_msghdr_t *hdr, void *src, bool copy=true) |
Publish a message via one of this driver's interfaces. More... | |
Driver (ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interf) | |
Constructor for single-interface drivers. More... | |
Driver (ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN) | |
Constructor for multiple-interface drivers. More... | |
virtual | ~Driver () |
Destructor. | |
int | GetError () |
Get last error value. More... | |
virtual int | Subscribe (QueuePointer &, player_devaddr_t) |
Subscribe to this driver. More... | |
virtual int | Unsubscribe (QueuePointer &, player_devaddr_t) |
Unsubscribe from this driver. More... | |
virtual int | Terminate () |
Terminate the driver. More... | |
void | ProcessMessages (int maxmsgs) |
Process pending messages. More... | |
void | ProcessMessages (void) |
Process pending messages. More... | |
virtual void | Update () |
Update non-threaded drivers. More... | |
virtual int | ProcessInternalMessages (QueuePointer &resp_queue, player_msghdr *hdr, void *data) |
Internal message handler. More... | |
virtual bool | RegisterProperty (const char *key, Property *property, ConfigFile *cf, int section) |
Property registration. More... | |
virtual bool | RegisterProperty (Property *property, ConfigFile *cf, int section) |
Property registration. More... | |
Private Member Functions | |
int | Connect () |
Connect. More... | |
int | Disconnect () |
Disconnect. More... | |
void | ResetRawPositions () |
ResetRawPositions. More... | |
void | ToggleMotorPower (unsigned char val) |
ToggleMotorPower. More... | |
void | ToggleAIn (unsigned char val) |
ToggleAIn. More... | |
void | ToggleSonar (unsigned char val) |
ToggleSonar. More... | |
int | HandleConfig (QueuePointer &resp_queue, player_msghdr *hdr, void *data) |
HandleConfig. More... | |
int | HandleCommand (player_msghdr *hdr, void *data) |
HandleCommand. More... | |
void | HandlePositionCommand (player_position2d_cmd_vel_t position_cmd) |
HandlePositionCommand. More... | |
void | PublishAllData () |
PublishAllData. | |
void | PublishPosition2D () |
PublishPosition2D. | |
void | PublishPower () |
PublishPower. | |
void | PublishAIn () |
PublishAIn. | |
void | PublishIR () |
PublishIR. | |
void | PublishSonar () |
PublishSonar. | |
void | StartThreads () |
StrarThreads. More... | |
void | StopThreads () |
StopThreads. | |
void | Send (mbasedriverPacket *packet) |
Send. More... | |
void | SendThread () |
SendThread. | |
void | ReceiveThread () |
ReceiveThread. More... | |
int | getms () |
getms More... | |
Static Private Member Functions | |
static void * | SendThreadDummy (void *driver) |
SedThreadDummy. | |
static void * | ReceiveThreadDummy (void *driver) |
ReceiveThreadDummy. | |
Private Attributes | |
int | mcount |
player_mbasedriver_data_t | mbasedriver_data |
player_devaddr_t | position_id |
player_devaddr_t | power_id |
player_devaddr_t | aio_id |
player_devaddr_t | ir_id |
player_devaddr_t | sonar_id |
int | position_subscriptions |
int | aio_ir_subscriptions |
int | sonar_subscriptions |
mbasedriverMotorPacket * | motor_packet |
pthread_mutex_t | motor_packet_mutex |
int | read_fd |
int | write_fd |
const char * | psos_serial_port |
player_position2d_cmd_vel_t | last_position_cmd |
player_position2d_cmd_car_t | last_car_cmd |
std::queue< mbasedriverPacket * > | send_queue |
pthread_mutex_t | send_queue_mutex |
pthread_cond_t | send_queue_cond |
pthread_t | send_thread |
pthread_t | receive_thread |
bool | print_all_packets |
int | param_idx |
int | motor_max_speed |
int | motor_max_turnspeed |
int | motor_trans_acel |
int | motor_rot_acel |
int | trans_ant |
int | rot_ant |
int16_t | pid_p |
int16_t | pid_v |
int16_t | pid_i |
int16_t | driffactor |
int16_t | dist_ejes |
int16_t | diametro |
bool | debug_usuario |
bool | ir_analog |
Additional Inherited Members | |
Public Attributes inherited from Driver | |
QueuePointer | ret_queue |
Last requester's queue. More... | |
player_devaddr_t | device_addr |
Default device address (single-interface drivers) | |
int | entries |
Total number of entries in the device table using this driver. More... | |
bool | alwayson |
Always on flag. More... | |
QueuePointer | InQueue |
Queue for all incoming messages for this driver. | |
Protected Member Functions inherited from Driver | |
int | AddInterface (player_devaddr_t addr) |
Add an interface. More... | |
int | AddInterface (player_devaddr_t *addr, ConfigFile *cf, int section, int code, const char *key=NULL) |
Add an interface. More... | |
void | SetError (int code) |
Set/reset error code. | |
virtual bool | Wait (double TimeOut=0.0) |
Wait for new data to arrive on the driver's queue. More... | |
int | AddFileWatch (int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true) |
Wake up the driver if the specified event occurs on the file descriptor. | |
int | RemoveFileWatch (int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true) |
Remove a previously added watch, call with the same arguments as when adding the watch. | |
virtual void | Lock (void) |
Lock access between the server and driver threads. More... | |
virtual void | Unlock (void) |
Unlock access to driver internals. More... | |
virtual void | SubscriptionLock (void) |
Lock to protect the subscription count for the driver. | |
virtual void | SubscriptionUnlock (void) |
Unlock to protect the subscription count for the driver. More... | |
virtual void | TestCancel () |
enable thread cancellation and test for cancellation More... | |
Constructor & Destructor Documentation
◆ mbasedriver()
mbasedriver::mbasedriver | ( | ConfigFile * | cf, |
int | section | ||
) |
- Constructor of the driver from configuration entry
Leyendo los datos del fichero cfg y asignando valores a los parámetros correspondientes.
References ConfigFile::ReadDeviceAddr().
Member Function Documentation
◆ Connect()
|
private |
Connect.
- Establishes connection and starts threads
Envío mensajes de configuración a la placa de control IOM
- OPEN_CONTROLLER
- STOP
- SET_TRANS_ACEL, si no se envía al menos una vez la plataforma no se moverá
- SET_ROT_ACEL -> No se envia porque el IOM no lo reconoce
if(this->motor_rot_acel > 0) { accel_packet = new mbasedriverPacket(); accel_command[0] = (command_e)set_rot_acel; accel_command[1] = (argtype_e)argint; accel_command[2] = this->motor_rot_acel & 0x00FF; accel_command[3] = (this->motor_rot_acel & 0xFF00) >> 8; if(debug_send) printf("__ build SET_ROT_ACEL\n"); accel_packet->Build(accel_command, 4); this->Send(accel_packet); }
- SET_DRIFFACTOR
- SET_ROBOT_WIDTH
- SET_ROBOT_WHEEL
- SET_PID_P
- SET_PID_I
- SET_PID_D
References mbasedriverPacket::Build(), mbasedriverPacket::Receive(), mbasedriverPacket::Send(), and Send().
◆ Disconnect()
|
private |
Disconnect.
- Is theoretically able to disconnect, but we don't do that
References mbasedriverPacket::Build(), mbasedriverPacket::Send(), and StopThreads().
◆ getms()
|
private |
◆ HandleCommand()
|
private |
HandleCommand.
- Switchboard for robot commands, called from ProcessMessage
- Note that these don't perform a response...
References HandlePositionCommand(), Message::MatchMessage(), PLAYER_MSGTYPE_CMD, and PLAYER_POSITION2D_CMD_VEL.
Referenced by ProcessMessage().
◆ HandleConfig()
|
private |
HandleConfig.
- Handles one Player command with a configuration request
References mbasedriverPacket::Build(), Message::MatchMessage(), player_pose2d::pa, PLAYER_IR_REQ_POSE, PLAYER_MSGTYPE_REQ, PLAYER_MSGTYPE_RESP_ACK, PLAYER_POSITION2D_REQ_GET_GEOM, PLAYER_POSITION2D_REQ_MOTOR_POWER, PLAYER_POSITION2D_REQ_RESET_ODOM, PLAYER_POSITION2D_REQ_SET_ODOM, PLAYER_SONAR_DATA_GEOM, PLAYER_SONAR_REQ_GET_GEOM, PLAYER_WARN, player_position2d_geom::pose, player_position2d_set_odom_req::pose, player_sonar_geom::poses, player_ir_pose::poses, player_sonar_geom::poses_count, player_ir_pose::poses_count, Driver::Publish(), player_pose2d::px, player_pose3d::px, player_pose2d::py, player_pose3d::py, player_pose3d::pyaw, Send(), player_msghdr::size, player_position2d_geom::size, player_bbox3d::sl, player_position2d_power_config::state, player_bbox3d::sw, and ToggleMotorPower().
Referenced by ProcessMessage().
◆ HandlePositionCommand()
|
private |
HandlePositionCommand.
- Handles one Player command detailing a velocity
References mbasedriverPacket::Build(), getms(), player_pose2d::pa, player_pose2d::px, Send(), and player_position2d_cmd_vel::vel.
Referenced by HandleCommand().
◆ Main()
|
virtual |
Main.
- Main entry point for the worker thread
if(!last_position_subscrcount && this->position_subscriptions) { this->ToggleMotorPower(0); this->ResetRawPositions(); } else if(last_position_subscrcount && !(this->position_subscriptions)) { enable motor power this->ToggleMotorPower(1); }
if(!last_aio_ir_subscriptions && this->aio_ir_subscriptions) this->ToggleAIn(1); else if(last_aio_ir_subscriptions && !(this->aio_ir_subscriptions)) this->ToggleAIn(0);
if(!last_sonar_subscriptions && this->sonar_subscriptions) this->ToggleSonar(1);
else if(last_sonar_subscriptions && !(this->sonar_subscriptions)) this->ToggleSonar(0);
References MessageQueue::Empty(), Driver::InQueue, and Driver::ProcessMessages().
◆ ProcessMessage()
|
virtual |
ProcessMessage.
- Gets called from ProcessMessages to handle one message
Reimplemented from Driver.
References HandleCommand(), HandleConfig(), PLAYER_MSGTYPE_CMD, PLAYER_MSGTYPE_REQ, and player_msghdr::type.
◆ ReceiveThread()
|
private |
ReceiveThread.
- Listens to the robot
References mbasedriverMotorPacket::Fill(), mbasedriverMotorPacket::Parse(), mbasedriverPacket::Print(), mbasedriverPacket::PrintHex(), PublishAIn(), PublishIR(), PublishPosition2D(), PublishPower(), PublishSonar(), and mbasedriverPacket::Receive().
◆ ResetRawPositions()
|
private |
ResetRawPositions.
- Tells the robot to reset the odometry center
References mbasedriverPacket::Build(), and Send().
◆ Send()
|
private |
Send.
- Queues for sending
Referenced by Connect(), HandleConfig(), HandlePositionCommand(), ResetRawPositions(), ToggleAIn(), ToggleMotorPower(), and ToggleSonar().
◆ Setup()
|
virtual |
◆ Shutdown()
|
virtual |
◆ StartThreads()
|
private |
StrarThreads.
- These call the supplied Driver::StartThread() method, but adds additional threads
References ReceiveThreadDummy(), and SendThreadDummy().
◆ Subscribe()
|
virtual |
Subscribe.
- Subscription is overridden to add a subscription count of our own
Reimplemented from Driver.
References Device::MatchDeviceAddress(), Driver::Subscribe(), ToggleAIn(), ToggleMotorPower(), and ToggleSonar().
◆ ToggleAIn()
|
private |
ToggleAIn.
- Enable or disable analog input reporting
References mbasedriverPacket::Build(), and Send().
Referenced by Subscribe(), and Unsubscribe().
◆ ToggleMotorPower()
|
private |
ToggleMotorPower.
- Enable or disable motors
References mbasedriverPacket::Build(), and Send().
Referenced by HandleConfig(), Subscribe(), and Unsubscribe().
◆ ToggleSonar()
|
private |
ToggleSonar.
- Enable or disable sonar reporting
References mbasedriverPacket::Build(), and Send().
Referenced by Subscribe(), and Unsubscribe().
The documentation for this class was generated from the following files:
- mbasedriver.h
- mbasedriver.cc