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)
 Subscribe.
virtual int Unsubscribe (player_devaddr_t id)
 Unsubscribe.
virtual void Main ()
 Main.
virtual int Setup ()
 Setup.
virtual int Shutdown ()
 Shutdown.
virtual int ProcessMessage (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
 ProcessMessage.

Private Member Functions

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

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

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]

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(), Send(), and mbasedriverPacket::Send().

Referenced by mbasedriver().

Here is the call graph for this function:

int mbasedriver::Disconnect ( ) [private]

Disconnect.

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

getms

  • function to get the time in ms

Referenced by HandlePositionCommand().

int mbasedriver::HandleCommand ( player_msghdr hdr,
void *  data 
) [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().

Here is the call graph for this function:

void mbasedriver::HandlePositionCommand ( player_position2d_cmd_vel_t  position_cmd) [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().

Here is the call graph for this function:

void mbasedriver::Main ( void  ) [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 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]

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.

Here is the call graph for this function:

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

ResetRawPositions.

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

Setup.

  • Called by player when the driver is asked to connect

Reimplemented from Driver.

int mbasedriver::Shutdown ( void  ) [virtual]

Shutdown.

  • Called by player when the driver is supposed to disconnect

Reimplemented from Driver.

void mbasedriver::StartThreads ( ) [private]

StrarThreads.

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

Subscribe.

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

ToggleAIn.

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

ToggleMotorPower.

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

ToggleSonar.

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