Wirobot SDK Application Programming Interface (Api) Reference Manual - (For Ms Windows)
Wirobot SDK Application Programming Interface (Api) Reference Manual - (For Ms Windows)
Version: 1.3.0
January 2010
Table of Contents
I. Convention ...................................................................................................................................... 3
II. WiRobot SDK Overview ................................................................................................................ 4
III. WiRobot SDK API Reference for PMS5005.......................................................................... 6
III.1. Sensor Peripherals ................................................................................................................................ 6
III.1.1. Batch Sensor Data Updating API ............................................................................................ 6
III.1.2. Range and Distance Sensors .................................................................................................... 9
III.1.3. Human Sensors .......................................................................................................................... 10
III.1.4. Tilt and Acceleration Sensor.................................................................................................... 11
III.1.5. Temperature Sensors ................................................................................................................ 12
III.1.6. Infrared Remote Control Handling ......................................................................................... 13
III.1.7. Battery Voltage Monitors........................................................................................................ 14
III.1.8. Potentiometer Position Sensors ............................................................................................ 15
III.1.9. Motor Current Sensors..............................................................................................................16
III.1.10. Encoder ......................................................................................................................................... 17
III.1.11. Custom Analog and Digital Inputs and Outputs ..................................................................18
III.2. Motion Control ......................................................................................................................................20
III.2.1. DC Motor Control.......................................................................................................................20
III.2.2. RC Servo Motor Control ........................................................................................................... 31
III.3. Multimedia Control............................................................................................................................... 34
III.3.1. LCD Display ................................................................................................................................ 34
III.4. Events ..................................................................................................................................................... 34
IV. WiRobot SDK API Reference for PMB5010 ........................................................................ 36
IV.1. Multimedia Control............................................................................................................................... 36
IV.1.1. Audio Input and Output............................................................................................................ 36
IV.1.2. Image Capturing ......................................................................................................................... 38
IV.1.3. LCD Display ................................................................................................................................ 39
IV.2. Events ..................................................................................................................................................... 39
V. Power Controller API ................................................................................................................. 40
V.1. short GetVolRef( ) .............................................................................................................................. 40
V.2. short GetBat1Vol( ) ............................................................................................................................ 40
V.3. short GetBat1Temp( ) ........................................................................................................................ 40
V.4. short GetBat2Vol( )............................................................................................................................ 40
V.5. short GetBat2Temp( ) ........................................................................................................................ 41
V.6. short GetDCINVol() ............................................................................................................................. 41
V.7. byte GetCHGPath( ) ............................................................................................................................ 41
V.8. byte GetPowerPath( ) ........................................................................................................................ 41
V.9. byte GetCHGStatus( )......................................................................................................................... 42
V.10. void SendCmdCHG( ) .......................................................................................................................... 42
VI. Constellation system API ....................................................................................................... 44
Syntax
Syntax under each API reference is based on the C/C++ calling convention. Corresponding Visual
Basic calling convention can be found in relevant VB reference book, or from the WiRobot VB code
examples.
Under the WiRobot system architecture, all the controllers are connected in a chain. Programs
developed using WiRobot SDK runs on the Host as the central controller of each chain. All the
embedded controllers have at least two SCI ports for the system communications: upper-reach port
and lower-reach port, with the direction respect to the central controller. The WiRobot system
controller-level connection architecture is shown as Figure II.1.
The APIs described in this manual are the interface between the application-level software and the
WiRobot hardware system. Programs developed using WiRobot SDK runs on the PC sending and
receiving data to and from the WiRobot hardware via wire or wireless connection. The firmware on
the embedded controllers take care of all the low level operations of the system functional modules,
such as data acquisition, fast-loop low level motion control, image and audio capture and compression,
audio playback and wireless communication. They are transparent to the high level software system
running on the central PC controller. All the system software development can be carried on solely
under user-friendly PC system. WiRobot SDK for Windows is available for MS Visual C++ and MS
Visual Basic environment.
API exists as a MS ActiveX component, called WiRobot SDK ActiveX Module. User program uses
this component in VB or VC++ program to communicate with the WIRobot PMS5005 or/and
PMB5010 controllers. Data in between WiRobot hardware and the WiRobot SDK ActiveX Module
Standard Sensors: Sonar, human, infrared range, tilt/acceleration, temperature, battery voltage and
infrared remote control receiver
Motor Sensors: Potentiometers, current feedback sensors and encoders.
Custom Sensors: Custom expansion A/D inputs and digital inputs.
Description:
SystemMotorSensorRequest sends a request command to the WiRobot Sensing and
Motion Controller (PMS5005) in order to get the sensor data related to motor control.
SystemStandardSensorRequest sends a request command to the WiRobot Sensing and
Motion Controller (PMS5005) in order to get all the WiRobot standard sensor data.
SystemCustomSensorRequest sends a request command to the WiRobot Sensing and
Motion Controller (PMS5005) in order to get all custom-sensor data,
SystemAllSensorRequest sends a request command to the WiRobot Sensing and Motion
Controller (PMS5005) in order to get all the sensor data.
Description:
EnableMotorSensorSending enables batch updating motor-related sensor packets.
EnableStandardSensorSending enables batch updating standard sensor packets.
EnableCustomSensorSending enables batch updating custom sensor packets.
EnableAllSensorSending enables batch updating all the sensor packets.
Parameter: void
Return value: void
Remarks:
1. The latest request setting of the packet number and the update rate are used.
2. By default, all sensor data sending is enabled.
3. Please refer to the remarks under SystemMotorSensorRequest,
SystemSatndardSensorRequest, SystemCustomSensorRequest,
SystemAllSensorRequest
Description:
DisableMotorSensorSending disables batch updating motor-related sensor packets.
DisableStandardSensorSending disables batch updating standard sensor packets.
DisableCustomSensorSending disables batch updating custom sensor packets.
Parameter: void
Return value: void
Description:
SetSysMotorSensorPeriod sets refresh rate of batch updating motor-related sensor
packets.
SetSysStandardSensorPeriod sets refresh rate of batch updating standard sensor
packets.
SetSysCustomSensorPeriod sets refresh rate of batch updating custom sensor packets.
SetSysAllSensorPeriod sets refresh rate of batch updating all the sensor packets.
Parameter: short PeriodTime; /* Update period (in ms) for batch sensing
packets to PC central controller */
Return value: void
Remarks:
The default PeriodTime = 50 (ms), i.e. update rate is 20Hz. PeriodTime should be bigger
than 50 (ms), i.e. the system data fastest refresh rate is 20Hz.
Description:
GetSonarSensorX returns the current distance value between the relevant ultrasonic
range sensor module (DUR5200) and the object in front of it. The unit is cm.
Syntax: ival = GetSensorSonar1 (); // Sonar #1
ival = GetSensorSonar2 (); // Sonar #2
ival = GetSensorSonar3 (); // Sonar #3
ival = GetSensorSonar4 (); // Sonar #4
ival = GetSensorSonar5 (); // Sonar #5
ival = GetSensorSonar6 (); // Sonar #6
ival = GetSensorSonar (short channel); // Sonar #1, 2, 3, 4, 5, or 6
Parameter: void
short channel; // 0, 1, 2, 3, 4, or 5 for Sonar #1, 2, 3, 4, 5, 6
Return value: short ival;
Description:
GetSensorIRRange returns the current distance measurement value between the infrared
range sensor and the object in front of it.
Parameter: void
Return value: short ival;
Remarks:
The relationship between the return data and the distance is not linear. Please refer to the
sensors datasheet for distance-voltage curve. The data returned is the raw data of the
analog to digital converter. The output voltage of the sensor can be calculated from the
following equation:
Description:
GetSensorHumanAlarm returns the current human alarm data from DHM5150 Human
Motion Sensor Module. Please refer to the DHM5150 hardware manual for detailed
information.
st
Syntax: ival = GetSensorHumanAlarm1(); //1 human alarm
nd
ival = GetSensorHumanAlarm2 (); // 2 human alarm
Parameter: void
Return value: short ival;
Remarks:
To detect human presence, the application should compare the difference of two samples
(to detect the change from absence to presence), and also compare the sample data to a
user defined threshold (to determine whether to report an alarm or not). The threshold
determines the sensitivity of sensor. The higher the threshold is the lower the sensitivity
will be.
Description:
GetSensorHumanMotion returns the current human motion value from DHM5150 Human
Motion Sensor Module. Please refer to the DHM5150 hardware manual for detailed
information.
Parameter: void
Return value: short ival;
Remarks:
To detect human motion direction, the application should compare the difference of two
samples of each sensor modules output (to detect the change from absence to
presence), and then compare the sample data of the two sensor modules. For a single
source of human motion, the different patterns of the two sensor modules manifest the
directions of the motion. The relationship can be obtained from the experiments.
Description:
GetSensorTiltingX, GetSensorTiltingY, return the current tilt angle values in the relevant
directions from DTA5102 Tilting and Acceleration Sensor Module.
Parameter: void
Return value: short ival;
Remarks:
Description:
GetSensorOverheatADX returns the current air temperature values near the relevant DC
motor drive modules (MDM5253), which could be used for monitoring whether the motor
drivers are overheating or not. This situation usually occurs if the motor currents are kept
high (but still lower than the current limit of the motor driver module) for significant amount
of time, which may result from some unfavorable inner or external system conditions and is
not recommended for regular system operations.
st
Syntax: ival = GetSensorOverheatAD1(); //1 overheating sensor
nd
ival = GetSensorOverheatAD2(); //2 overheating sensor
Parameter: void
Return value: short ival;
Description:
GetSensorTemperature returns the current temperature value from DAT5280 Ambient
Temperature Sensor Module.
Description:
GetSensorIRCodeX returns the four parts of a two-16-bit-code infrared remote control
command captured by the Sensing and Motion Controller (PMS5005) through the Infrared
Remote Controller Module (MIR5500).
Parameter: void
Return value: short ival
Key Code: [the third byte] [the second byte] [the first byte]
Repeat Code: [the fourth byte]
Description:
SetInfraredControlOutput sends two 16-bit words infrared communication output data to
the Sensing and Motion Controller (PMS5005). The PMS5005 will then send the data out
through the infrared Remote Controller Module (MIR5500). In the case of being used for
infrared remote control, the output data serves as the remote control command.
st
Parameter: UWord16 LowWord; // 1 word
Copyright Dr Robot Inc. 2008
13
nd
UWord16 HighWord; // 2 word
Return value: void
Remarks:
1. In infrared communication application, the data format and the interpretation can
be defined by the user at the application level.
2. In infrared remote control application, the control command should be compatible
to the device to which the command is sent.
3. This API function is under development and will be available shortly.
Description:
GetSensorBatteryADX returns the current value of the relevant power supply voltage if
the battery voltage monitor is enabled (default), or returns the relevant custom A/D inputs,
if the custom A/D input is enabled which is configured by the jumpers on PMS5005. Please
refer to PMS5005 Robot Sensing and Motion Controller User Manual for detailed
information on hardware setting.
Parameter: void
Return value: short ival;
When monitoring the voltage of the power supply, following equations can be used to
calculate the real voltage values.
(1) Power supply voltage of DSP circuits = (ival / 4095) * 9 (V)
(2) Power supply voltage of DC motors = (ival / 4095) * 24 (V)
(3) Power supply voltage of servo motors = (ival / 4095) * 9 (V)
Description:
GetSensorRefVoltage returns the current value of the reference voltage of the A/D
converter of the controller DSP.
GetSensorPotVoltage returns the current value of the power supply voltage of the
potentiometer position sensors.
Parameter: void
Return value: short ival;
Description:
GetSensorPotX returns the current value of the relevant potentiometer position sensors.
GetSensorPot (short channel) returns the current value of the specified potentiometer
position sensor.
2. Single sensor is mainly used for the control of robot joint with limited rotation range.
The effective mechanical rotation range is 14 to 346, corresponding to the effective
electrical rotation range 0 to 332.
3. Dual-sensor configuration is mainly used for continuous rotating joint control (such as
wheels). The effective rotation range is 0 to 360. Dual sensor configuration is only
available for channel 0 and 1. By connecting two potentiometers to potentiometer
channel 0 and channel 5, and specify the sensor type with command
SetDCMotorSensorUsage() to Dual potentiometer sensor, the channel 0 reading
will combine these two sensor readings into 0 to 360 range. For channel 1, you
should connect the two potentiometers to channel 1 and 4.
Description:
GetMotorCurrentX returns the sampling value of motor current sensor.
III.1.10. Encoder
58 short GetEncoderDir1();
59 short GetEncoderDir2();
60 short GetEncoderPulse1();
61 short GetEncoderPulse2();
62 short GetEncoderSpeed1();
63 short GetEncoderSpeed2();
Description:
GetEncoderDirX returns +1, 0 or -1 to indicate the direction of rotation.
GetEncoderPulseX returns the current pulse counter to indicate the position of rotation.
GetEncoderSpeedX returns the current speed of rotation.
Parameter: void
Return value: short ival;
Description:
GetCustomADX returns the sampling value of the custom analog to digital input signals. By
default, custom AD1 - AD3 are used as the inputs of power supply voltage monitors for DSP
circuits, DC motors and servo motors. User can change this setting by configuring the
jumpers on PMS5005. Please refer to PMS5005 Robot Sensing and Motion Controller
hardware users manual for detailed information on hardware jumper setting.
Parameter: void
short channel; /* 0, 1, 2, 3, 4, 5, 6 or 7 for
channel #1, 2, 3, 4, 5, 6, 7, 8 */
Return value: short ival;
73 short GetCustomDIN();
Description:
GetCustomDIN returns a value with lower 8-bits corresponding to the 8-channel custom
digital inputs.
Parameter: void
Return value: short ival;
Remarks:
Only lower 8-bit is valid and reflects the 8 input channel states. The MSB of the lower byte
represents channel #8 and LSB of the lower byte represents channel #1.
Description:
SetCustomDOUT sets the 8-channel custom digital outputs.
Remarks:
Only the lower 8-bit is valid and can change the corresponding outputs of the 8 channels.
The MSB of the lower byte represents channel #8 and LSB of the lower byte represents
channel #1.
G + E U
Controller DC Motor
-
F
Potentiometer
In the case of PID control, the transfer function of the PID controller looks like as:
U (s) / E (s) K P K D S K I / S
When using potentiometers (optical encoder and etc.) as the rotational position feedback, you have to
set the motor polarity properly using WiRobotSDK ActiveX control API SetMotorPolarityX so
that the negative feedback is achieved. See SetMotorPolarityX for detail.
The control of the standard RC servo motors is carried out by the built-in analog PID controller.
Description:
SetMotorPolarityX set the motor polarity to 1 or -1 for each motor channel.
1. When the motor is running in positive direction, the potentiometer value is also
increasing; motor polarity should be set to 1 which is default.
2. When the motor is running in positive direction, the potentiometer value is decreasing,
motor polarity should be set to -1 or change the sensor mounting so that the
potentiometer value increases.
Description:
These functions are obsolete. Please see function ResumeDcMotor(short channel) and
SuspendDcMotor(short channel).
Description:
ResumeDcMotor resumes the specified DC motor control channel.
SuspendDcMotor suspends the specified DC motor control channel. PWM output is all low.
Remarks:
1. All motor control channels are initially suspended when the system boot-up.
86 void SetDcMotorPositionControlPID (short channel, short Kp, short Kd, short Ki_x100);
87 void SetDcMotorVelocityControlPID (short channel, short Kp, short Kd, short Ki_x100);
Description:
SetDcMotorPositionControlPID sets up the PID control parameters of the specified DC
motor channel for position control.
SetDcMotorVelocityControlPID sets up the PID control parameters of the specified DC
motor control channel for velocity.
Description:
This function is obsolete.
Description:
This filtering feature is still under development. All data will be treated as raw data.
Description:
SetDcMotorSensorUsage sets the sensor type for the specified DC motor control channel
on the Sensing and Motion Controller (PMS5005). The available sensor types are single
potentiometer, dual potentiometers, and quadrature encoder. The single potentiometer
sensor is for the control of robot joint with limited rotation range (0 to 332). The dual
potentiometers and the quadrature sensor are for continuous rotating joint (like wheels)
control.
Remarks:
1. The electrical angular range of the potentiometer position sensor is 0 to 332 and
the corresponding mechanical rotation range is 14 to 346, when the 180
position is defined at sensors physical middle position.
2. Each DC motor channel for dual potentiometer sensor utilizes two potentiometer
channels. DC motor channel 0 will use potentiometer channel 0 and 5; DC motor
channel 1 will use potentiometer channel 1 and 4; DC motor channel 2 will use
potentiometer channel 2 and 3. Please refer to the relevant application note for
the use of dual potentiometers.
3. Quadrature encoder will only use DC motor channel 0 and 1.
4. Systems default setting for sensor usage is single potentiometer.
Description:
SetDcMotorControlMode sets the control mode of the specified DC motor control channel
on the Sensing and Motion Controller (PMS5005). The available control modes are open-
loop PWM control, closed-loop position control, closed-loop velocity control.
Remarks:
Systems default setting for control mode is Open-loop PWM Control.
Description:
DcMotorPositionTimeCtr sends the position control command to the specified motion
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target position and the target time period to execute the command. The current
trajectory planning method with time control is linear.
Remarks:
1. Motor will be enabled automatically by the system when this command is received.
2. Target position value is in the A/D sampling data range 0 to 4095 when using
single potentiometer, 0-4428 when using dual potentiometers.
3. Please refer to the description of GetSensorPot for data converting between
angular values and the A/D sampling data values.
4. When using encoder as sensor input, the target position value is the pulse count in
the range of 0- 32767.
Description:
DcMotorPositionNonTimeCtr sends the position control command to the specified motion
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target position but no time period specified to execute the command. The motion
controller will drive the motor to the target position at the maximum speed.
Remarks:
1. Motor will be enabled automatically by the system when this command is received.
2. Target position value is in the A/D sampling data range 0 to 4095 when using
single potentiometer, 0-4428 when using dual potentiometers.
3. Please refer to the description of GetSensorPot for data converting between
angular values and the A/D sampling data values.
4. When using encoder as sensor input, the target position value is the pulse count in
the range of 0- 32767.
Description:
DcMotorVelocityTimeCtr sends the velocity control command to the specified motion
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target velocity and the time period to execute the command. The current trajectory
planning method for time control is linear.
Remarks:
1. Motor will be enabled automatically by the system when this command is received
2. No velocity is available for motor channel using single potentiometer sensor
3. The unit of the velocity is (Position change in A/D sampling data) / second when
using dual potentiometer sensor for rotational position measurement and pulse/
second when using quadrature encoder.
4. Please refer to the description of GetSensorPot for data conversion between
angular values and the A/D sampling data values.
Description:
DcMotorVelocityNonTimeCtr sends the velocity control command to the specified motion
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target velocity but no time period specified to execute the command. The motion
controller will drive the motor to achieve the target velocity with maximum effort.
Remarks:
1. Motor will be enabled automatically by the system when this command is received
2. No velocity is available for motor channel using single potentiometer sensor
Description:
DcMotorPwmTimeCtr sends the PWM control command to the specified motion control
channel on the Sensing and Motion Controller (PMS5005). The command includes the
target pulse width value and the time period to execute the command. The current
trajectory planning method for time control is linear.
Remarks:
1. The specified channel (motor) will be enabled automatically by the system when
this command is received
2. Target pulse width value range is 0 to 32767 (0x7FFF), corresponding to the duty
cycle of 0 to 100% linearly.
3. A pulse width value of 16383 means 50% duty cycle, putting motor in Stop stage.
Any value in between 16384 - 32767 will put the motor to turn clockwise (facing
the front side of the motor) and any value in between 0 16362 will put the motor
to turn counter-clockwise.
Description:
DcMotorPwmNonTimeCtr sends the PWM control command to the specified motion
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target pulse width value without specific execution time period. The motion controller
will set the PWM output of this channel to the target value immediately.
Remarks:
1. The specified channel (motor) will be enabled automatically by the system when
this command is received
2. Target pulse width value range is 0 to 32767 (0x7FFF), corresponding to the duty
cycle of 0 to 100% linearly.
3. A pulse width value of 16383 means 50% duty cycle, putting motor in Stop stage.
Any value in between 16384 - 32767 will put the motor to turn clockwise (facing
the front side of the motor) and any value in between 0 16362 will put the motor
to turn counter-clockwise.
Description:
DcMotorPositionTimeCtrAll sends the position control command to all 6 DC motor control
channels on the sensing and motion controller (PMS5005) at the same time. The command
includes the target positions and the time period to execute the command. The current
trajectory planning method for time control is linear.
Remarks:
1. All DC Motors will be enabled automatically by the system when this command is
received.
2. Target position value is in the A/D sampling data range 0 to 4095 when using
single potentiometer, 0-4428 when using dual potentiometers.
3. Please refer to the description of GetSensorPot for data converting between
angular values and the A/D sampling data values.
4. When using encoder as sensor input, the target position value is the pulse count in
the range of 0- 32767.
5. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
Copyright Dr Robot Inc. 2008
27
See also: DcMotorPositionTimeCtr,
Description:
DcMotorPositionNonTimeCtrAll sends the position control command to all 6 DC motor
control channels on the Sensing and Motion Controller (PMS5005) at the same time. The
command includes the target positions without specific execution time period. The motion
controller will drive the motor to reach the target position with maximum effort.
Remarks:
1. All DC motors will be enabled automatically by the system when this command is
received.
2. Target position value is in the A/D sampling data range 0 to 4095 when using
single potentiometer, 0-4428 when using dual potentiometers.
3. Please refer to the description of GetSensorPot for data converting between
angular values and the A/D sampling data values.
4. When using encoder as sensor input, the target position value is the pulse count in
the range of 0- 32767.
5. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
100 void DcMotorVelocityTimeCtrAll(short cmd1, short cmd2, short cmd3, short cmd4,
short cmd5, short cmd6, short timePeriods);
Description:
DcMotorVelocityTimeCtrAll sends the velocity control command to all 6 DC motor control
channels on the Sensing and Motion Controller (PMS5005) at the same time. The
command includes the target velocities and the time period to execute the command. The
trajectory planning method for time control is linear.
Remarks:
1. Motor will be enabled automatically by the system when this command is received
2. No velocity is available for motor channel using single potentiometer sensor
3. The unit of the velocity is (Position change in A/D sampling data) / second when
using dual potentiometer sensor for rotational position measurement and pulse/
second when using quadrature encoder.
4. Please refer to the description of GetSensorPot for data conversion between
angular values and the A/D sampling data values.
5. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
Description:
DcMotorVelocityNonTimeCtrAll sends the velocity control command to all 6 DC motor
control channels on the Sensing and Motion Controller (PMS5005) at the same time. The
command includes the target velocities without specific execution time period. The motion
controller will drive the motor to achieve the target velocity with maximum effort.
102 void DcMotorPwmTimeCtrAll(short cmd1, short cmd2, short cmd3, short cmd4,
short cmd5, short cmd6, short timePeriods);
Description:
DcMotorPwmTimeCtrAll sends the PWM control command to all 6 DC motor control
channels on the Sensing and Motion Controller (PMS5005) at the same time. The
command includes the target PWM values and the time period to execute the command.
The current trajectory planning method for time control is linear.
Remarks:
1. All channel (motors) will be enabled automatically by the system when this
command is received
2. Target pulse width value range is 0 to 32767 (0x7FFF), corresponding to the duty
cycle of 0 to 100% linearly.
3. A pulse width value of 16383 means 50% duty cycle, putting motor in Stop stage.
Any value in between 16384 - 32767 will put the motor to turn clockwise (facing
the front side of the motor) and any value in between 0 16362 will put the motor
to turn counter-clockwise.
4. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
Description:
DcMotorPwmNonTimeCtrAll sends the PWM control command to all 6 DC motor control
channels on the Sensing and Motion Controller (PMS5005) at the same time. The
command includes the target PWM values without specific execution time period. The
motion controller Send the desired PWM pulse width right away.
Remarks:
1. All channel (motors) will be enabled automatically by the system when this
command is received
2. Target pulse width value range is 0 to 32767 (0x7FFF), corresponding to the duty
cycle of 0 to 100% linearly.
3. A pulse width value of 16383 means 50% duty cycle, putting motor in Stop stage.
Any value in between 16384 - 32767 will put the motor to turn clockwise (facing
the front side of the motor) and any value in between 0 16362 will put the motor
to turn counter-clockwise.
4. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
Description:
EnableServo enables the specified servo motor control channel.
DisableServo disables the specified servo motor control channel.
Remarks:
All servo motor channels are disabled initially at system startup. They need to be enabled
explicitly before use.
Description:
This function is obsolete.
Description:
ServoTimeCtr sends the position control command to the specified servo motor control
channel on the Sensing and Motion Controller (PMS5005). The command includes the
target position command and the time period to execute the command. The current
trajectory planning method for time control is linear.
Remarks:
1. Target position value for cmdValue = (Pulse width in millisecond) * 2250.
2. Usually, a standard remote control servo motor expects to get the specified pulse
width in every 20 milliseconds in order to hold the corresponding angle position.
The pulse width value in millisecond for 0, 90 and 180 are servo manufacturer
and model dependant, they are around 1ms, 1.5ms and 2.0ms respectively for most
common servos. Experiments are required to obtain the exact value which varies
for different servo motors.
Description:
ServoNonTimeCtr sends the position control command to the specified servo motor
control channel on the Sensing and Motion Controller (PMS5005). The command includes
the target position command without specific execution time period. The motion controller
will send the desired pulse width to the servo motor right away.
Remarks:
Please refer to the remarks under ServoTimeCtr.
109 void ServoTimeCtrAll(short cmd1, short cmd2, short cmd3, short cmd4,
short cmd5, short cmd6, short timePeriod);
Description:
ServoTimeCtrAll sends the position control command to all 6 servo motor control channels
on the Sensing and Motion Controller (PMS5005) at the same time. The command includes
the target position commands and the time period to execute the command. The current
trajectory planning method for time control is linear.
Remarks:
1. Please refer to the remarks under ServoTimeCtr.
2. When some servo motors are not under controlled, their command values should be
set as -32768 (0x8000). That means NO_CONTROL.
110 void ServoNonTimeCtrAll (short cmd1, short cmd2, short cmd3, short cmd4,
short cmd5, short cmd6);
Description:
Remarks:
1. Please refer to the remarks under ServoTimeCtr
2. When some motors are not under controlled, their command values should be set
as -32768 (0x8000). That means NO_CONTROL.
Description:
LcdDisplayPMS displays the image data in the file bmpFileName (BMP format) on the
graphic LCD connected to the Sensing and Motion Controller (PMS5005).
Parameter: LPCTSTR bmpFileName; // Full path of the BMP file for displaying
Return value: void
Remarks:
The graphic LCD display is mono with dimension of 128 pixels by 64 pixels. The bmp image
must be 128x64 pixels in mono.
III.4. Events
112 StandardSensorEvent
Description:
When the standard sensor data arrive, this event will be triggered.
113 CustomSensorEvent
Description:
When the custom expansion sensor (AD and Input) data arrive, this event will be triggered.
114 MotorSensorEvent
Description:
When the motor control related sensor data arrive, this event will be triggered. The motor
control data includes all the motor rotational sensor data such as potentiometer, encoder
and motor current data.
Description:
PlayAudioFile sends an audio file (.wav format) to the Multimedia Controller (PMB5010).
The file will be played back on the speaker.
Remarks:
The .wav audio file should contain 16-bit sound wave data sampled at 8 kHz with PCM raw
data format using mono channel. Other supplied wave file format will still be played by the
robot but may have undesired result.
Description:
StopAudioPlay stops a playing audio on the Multimedia Controller (PMB5010).
Remarks:
There will be no effect if no audio is playing.
Description:
GetVoiceSegment returns the pointer to current voice data (recorded from robot
microphone) in memory.
Remark:
(1) You should use method GetVoiceSegLength() to get the length of the Voice
segment.
(2) Voice data is in PCM raw data format with 16bit, 8KHz sampling rate.
Description:
GetVoiceSegLength returns the length of current voice data in memory.
Parameter: void
Return value: long voiceLength; // Length of current voice data.
Description:
StartRecord sends start-recording command to the Multimedia Controller (PMB5010).
The recorded voice data in length specified by voiceSegment will be stored in the shared
memory segment.
Syntax: StartRecord(voiceSegment);
Parameter: short voiceSegment; // segment number for voice data, range 1 -10
Return value: void
Remarks:
The parameter voiceSegment specify the time of voice segment, unit is 256 millisecond
(about 1/4 sec). Value could be 1- 10. For example, if voiceSegment is 4, 1.024 second
voice will be recorded. VoiceSegmentEvent event will fired when the data is ready.
Description:
Syntax: StopRecord();
Parameter: void
Return value: void
Remarks:
There will be no effect if the Multimedia Controller is not recording.
Description:
TakePhoto sends image capturing command to the Multimedia Controller (PMB5010).
The Multimedia Controller will send back the latest frame of the image data to the WiRobot
shared memory after receiving TakePhoto command. Use SavePhotoAsBMP to obtain the
image.
Syntax: TakePhoto();
Parameter: void
Return value: void
Remarks:
Each TakePhoto command will get one frame of image.
Description:
SavePhotoAsBMP saves current frame of image data into BMP format file FileName.
Parameter: LPCTSTR FileName; // the file name with full path, for saving image
data in bmp format.
Return value: BOOL bVal; // True: success
// False: failure to save.
Remarks:
1. Before calling SavePhotoAsBMP, the TakePhoto command needs to be called to
request image taken.
Description:
LcdDisplayPMB displays the image data in the file bmpFileName (BMP format) on the
graphic LCD connected to the Multimedia Controller (PMB5010).
Parameter: LPCTSTR bmpFileName; // Full path of the BMP file for displaying
Return value: void
Remarks:
The graphic LCD display is mono with dimension of 128 pixels by 64 pixels. The bmp image
must be 128x64 pixels in mono.
IV.2. Events
This section documents the two Event mechanisms. When the relevant data arrive from the WiRobot
PMB5010 system, relevant event will be fired, user could write his / her periodic data processing
routine in the relevant event call back function.
124 ImageEvent
Description:
When the image data arrive, this event will be triggered.
125 VoiceSegmentEvent
Description:
When the audio data arrive, this event will be triggered.
Bit Description
0 X
1 X
2 X
3 X
4 X
5 Power by DCIN
6 Power by Battery 2
7 Power by Battery 1
Bit Description
0 Reset WIFI1 power 0 reset 200ms
1 Reset TI 1 power 0 reset 200ms
2 Motor805 power 1power 0 turn off
3 Power by DCIN
VI.9. void setGPSID(Byte id1, Byte id2, Byte id3, Byte id4)
Description:
Set the ID of Constellation transponder that the robot will be using.
Syntax: void setGPSID(Byte id1, Byte id2, Byte id3, Byte id4)
Parameter: Byte id1, Byte id2, Byte id3, Byte id4
Return value: void
Remarks:
The sensor with id1, id2 is on the one Constellation transponder, and the sensor
with id3,id4 is on another transponder.
Step 1:
Set the transponder ID to 1,2,3,4:
setGPSID(1,2,3,4);
Step 2:
Get the distance in the custom sensor event.
Step 3:
Calculate the position based on the information of distance measurement.
Here is the example for transponder 1( with sensor ID = 1, sensor ID = 2)
If all the data are effective, then we should be able to calculate the position of left receiver
(xL,yL,zL) and right receiver (xR,yR,zR) position by simple triangle functions.
L3
L4
L1 (xR,yR,zR)
L2
CarSensorDis
(xL,yL,zL)
CarHeight