mbasedriver Class Reference
Inheritance diagram for mbasedriver:
Collaboration diagram for mbasedriver:

List of all members.

Public Member Functions

 mbasedriver (ConfigFile *cf, int section)
virtual int Subscribe (player_devaddr_t id)
virtual int Unsubscribe (player_devaddr_t id)
virtual void Main ()
virtual int Setup ()
virtual int Shutdown ()
virtual int ProcessMessage (QueuePointer &resp_queue, player_msghdr *hdr, void *data)

Private Member Functions

int Connect ()
int Disconnect ()
void ResetRawPositions ()
void ToggleMotorPower (unsigned char val)
void ToggleAIn (unsigned char val)
void ToggleSonar (unsigned char val)
int HandleConfig (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
int HandleCommand (player_msghdr *hdr, void *data)
void HandlePositionCommand (player_position2d_cmd_vel_t position_cmd)
void PublishAllData ()
void PublishPosition2D ()
void PublishPower ()
void PublishAIn ()
void PublishIR ()
void PublishSonar ()
void StartThreads ()
void StopThreads ()
void Send (mbasedriverPacket *packet)
void SendThread ()
void ReceiveThread ()
int getms ()

Static Private Member Functions

static void * SendThreadDummy (void *driver)
static void * ReceiveThreadDummy (void *driver)

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
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

Constructor & Destructor Documentation

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 Driver::AddInterface(), Connect(), ConfigFile::ReadAngle(), ConfigFile::ReadDeviceAddr(), ConfigFile::ReadInt(), ConfigFile::ReadLength(), ConfigFile::ReadString(), and Driver::SetError().

Here is the call graph for this function:

Member Function Documentation

int mbasedriver::Connect ( ) [private]


  • Establishes connection and starts threads

Envío mensajes de configuración a la placa de control IOM

  • 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_PID_I
    • SET_PID_D

References mbasedriverPacket::Build(), mbasedriverPacket::Receive(), Send(), and mbasedriverPacket::Send().

Referenced by mbasedriver().

Here is the call graph for this function:

int mbasedriver::Disconnect ( ) [private]


  • Is theoretically able to disconnect, but we don't do that

References mbasedriverPacket::Build(), mbasedriverPacket::Send(), and StopThreads().

Here is the call graph for this function:

int mbasedriver::getms ( ) [private]


  • function to get the time in ms

Referenced by HandlePositionCommand().

int mbasedriver::HandleCommand ( player_msghdr hdr,
void *  data 
) [private]


  • 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().

Here is the call graph for this function:

void mbasedriver::HandlePositionCommand ( player_position2d_cmd_vel_t  position_cmd) [private]


  • 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().

Here is the call graph for this function:

void mbasedriver::Main ( void  ) [virtual]


  • 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 Driver::InQueue, and Driver::ProcessMessages().

Here is the call graph for this function:

int mbasedriver::ProcessMessage ( QueuePointer resp_queue,
player_msghdr hdr,
void *  data 
) [virtual]


  • Gets called from ProcessMessages to handle one message

Reimplemented from Driver.

References HandleCommand(), HandleConfig(), PLAYER_MSGTYPE_CMD, PLAYER_MSGTYPE_REQ, and player_msghdr::type.

Here is the call graph for this function:

void mbasedriver::ReceiveThread ( ) [private]
void mbasedriver::ResetRawPositions ( ) [private]


  • Tells the robot to reset the odometry center

References mbasedriverPacket::Build(), and Send().

Here is the call graph for this function:

void mbasedriver::Send ( mbasedriverPacket packet) [private]
int mbasedriver::Setup ( void  ) [virtual]


  • Called by player when the driver is asked to connect

Reimplemented from Driver.

int mbasedriver::Shutdown ( void  ) [virtual]


  • Called by player when the driver is supposed to disconnect

Reimplemented from Driver.

void mbasedriver::StartThreads ( ) [private]


  • These call the supplied Driver::StartThread() method, but adds additional threads

References ReceiveThreadDummy(), and SendThreadDummy().

Here is the call graph for this function:

int mbasedriver::Subscribe ( player_devaddr_t  id) [virtual]


  • Subscription is overridden to add a subscription count of our own

Reimplemented from Driver.

References Device::MatchDeviceAddress(), Driver::Subscribe(), ToggleAIn(), ToggleMotorPower(), and ToggleSonar().

Here is the call graph for this function:

void mbasedriver::ToggleAIn ( unsigned char  val) [private]


  • Enable or disable analog input reporting

References mbasedriverPacket::Build(), and Send().

Referenced by Subscribe(), and Unsubscribe().

Here is the call graph for this function:

void mbasedriver::ToggleMotorPower ( unsigned char  val) [private]


  • Enable or disable motors

References mbasedriverPacket::Build(), and Send().

Referenced by HandleConfig(), Subscribe(), and Unsubscribe().

Here is the call graph for this function:

void mbasedriver::ToggleSonar ( unsigned char  val) [private]


  • Enable or disable sonar reporting

References mbasedriverPacket::Build(), and Send().

Referenced by Subscribe(), and Unsubscribe().

Here is the call graph for this function:

The documentation for this class was generated from the following files: