kb_khepera3.c File Reference

This module is layer for communication with various devices which are part of the khepera3 robot. It offers simple interface to the user. More...

Include dependency graph for kb_khepera3.c:

Go to the source code of this file.

Defines

#define PULSE_TO_MM_FIRMWARE_S_3   0.04629
#define PULSE_TO_MM_FIRMWARE_BE_3   0.03068
#define MM_S_TO_SPEED_FIRMWARE_S_3   144.01
#define MM_S_TO_SPEED_FIRMWARE_BE_3   218.72

Functions

int kh3_init (void)
int kh3_getcommand (knet_dev_t *hDev, unsigned char *out)
int kh3_sendcommand (knet_dev_t *hDev, unsigned char *in)
int kh3_proximity_ir (char *outbuf, knet_dev_t *hDev)
int kh3_ambiant_ir (char *outbuf, knet_dev_t *hDev)
int kh3_battery_voltage (char *outbuf, unsigned char argument, knet_dev_t *hDev)
int kh3_reset_tstamp (char *outbuf, knet_dev_t *hDev)
int kh3_revision (char *outbuf, knet_dev_t *hDev)
int kh3_configure_os (char *outbuf, unsigned char index, unsigned char value, knet_dev_t *hDev)
int kh3_measure_us (char *outbuf, unsigned char usnbr, knet_dev_t *hDev)

Variables

double kh3_pulses_to_mm = PULSE_TO_MM_FIRMWARE_S_3
double kh3_mms_to_speed = MM_S_TO_SPEED_FIRMWARE_S_3

Detailed Description

This module is layer for communication with various devices which are part of the khepera3 robot. It offers simple interface to the user.

Khepera3 layer

Author:
Arnaud Maye (K-Team SA)
Note:
Copyright (C) 2005 K-TEAM SA
Bug:
none discovered.
Todo:
nothing.

Definition in file kb_khepera3.c.


Define Documentation

#define MM_S_TO_SPEED_FIRMWARE_BE_3   218.72

Definition at line 26 of file kb_khepera3.c.

Referenced by main().

#define MM_S_TO_SPEED_FIRMWARE_S_3   144.01

Definition at line 25 of file kb_khepera3.c.

Referenced by main().

#define PULSE_TO_MM_FIRMWARE_BE_3   0.03068

Definition at line 22 of file kb_khepera3.c.

Referenced by main().

#define PULSE_TO_MM_FIRMWARE_S_3   0.04629

Definition at line 21 of file kb_khepera3.c.

Referenced by main().


Function Documentation

int kh3_ambiant_ir ( char *  outbuf,
knet_dev_t hDev 
)

kh3_ambiant_ir retrieves an instant IR measure.

Parameters:
outbuf is a buffer where the data will be stored on.
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 206 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by ambIR(), BinaryRead(), and ReadAmbSensors().

Here is the call graph for this function:

int kh3_battery_voltage ( char *  outbuf,
unsigned char  argument,
knet_dev_t hDev 
)

kh3_battery_Voltage retrieves the actual battery voltage.

Parameters:
outbuf is a buffer where the data will be stored on.
argument parameter of the command
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 244 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by batStatus(), main(), and voltageBAT().

Here is the call graph for this function:

int kh3_configure_os ( char *  outbuf,
unsigned char  index,
unsigned char  value,
knet_dev_t hDev 
)

kh3_configure configures the current firmware operation mode. a configuration array is used by the khepera3 to decide its mode of operation.

Parameters:
outbuf is a buffer where the data will be stored on.
index is the index pointing one of the configuration word in the config array.
value is the value to store in the configuration array.
hDev is a handle to an openned knet socket (Khepera3:dsPic).

Indexes:

  • 0 : Value that tells on which us transciever to work from This is a bit field where bit0 means trx 1 and so on So to work on the two most left transceiver one should Set 0b0000000000000011 => 3. Note: default value is 4 to work from only the front us trx.
  • 1 : Value that decide what is the maximum echo number Note: default value is 3.
  • 2 : Value that tell how many pulse can be seen without the echo is detected. This is required because the korebot may generate some noise. A received echo means many 40kHz pulse so this is why we can filter noise that way. Note: default value is 5.
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 387 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by configureOS(), getallus(), and main().

Here is the call graph for this function:

int kh3_getcommand ( knet_dev_t hDev,
unsigned char *  out 
)

kh3_getcommand gets a command frame from a given khepera3 device.

Function flow:

  • a) : retrieve the first byte which is the frame size from the device
  • b) : retrieve the required bytes

Normally an end user don't want to use these function as they are assumed as "low level functions".

Parameters:
hDev is a handle to an openned knet socket (Khepera3:dsPic).
out is a pointer to a buffer where the command frame will be stored on.
Returns:
A value:
  • <0 on error (KH3_ERROR_FRMSZERR, KH3_ERROR_SZFMTERR)
  • >=0 on success (returns should be the size of frame)
Remarks:
This function requires that kb_kh3_init has been called

Definition at line 99 of file kb_khepera3.c.

References KB_ERROR, KB_ERROR_KH3FRMSZERR, KB_ERROR_KH3SZFMTERR, KH3_ERROR_FRMSZ, KH3_ERROR_SZFMT, and knet_llread().

Referenced by kh3_ambiant_ir(), kh3_battery_voltage(), kh3_configure_os(), kh3_measure_us(), kh3_proximity_ir(), kh3_reset_tstamp(), kh3_revision(), and SetLED().

Here is the call graph for this function:

int kh3_init ( void   ) 

kh3_init initializes some things like the GPIO40 pin. This function needs to be called BEFORE any other functions.

Returns:
A value:
  • <0 on error
  • =0 on success

Definition at line 43 of file kb_khepera3.c.

References IN, KB_ERROR, KB_ERROR_KH3KBINIT, kb_gpio_dir(), kb_gpio_function(), kb_gpio_init(), kb_init(), KH3_ERROR_GPIO, KH3_ERROR_KBINIT, KH3_ERROR_SUCCESS, and KNET_INT0.

Referenced by initKH3(), and main().

Here is the call graph for this function:

int kh3_measure_us ( char *  outbuf,
unsigned char  usnbr,
knet_dev_t hDev 
)

kh3_measure_us retrieves measure from a given US transmitter.

Parameters:
outbuf is a buffer where the data will be stored on.
usnbr is a number of the us trx to read from ( 1 to 5 ).
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 425 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by getallus(), GetUS(), main(), and measureUS().

Here is the call graph for this function:

int kh3_proximity_ir ( char *  outbuf,
knet_dev_t hDev 
)

kh3_proximity_ir retrieves an instant IR measure.

Parameters:
outbuf is a buffer where the data will be stored on.
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 167 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by BinaryRead(), braitenberg(), braitenbergAvoidance(), main(), proxIR(), and ReadProxSensors().

Here is the call graph for this function:

int kh3_reset_tstamp ( char *  outbuf,
knet_dev_t hDev 
)

kh3_reset_tstamp resets the absolute timestamp.

Parameters:
outbuf is a buffer where the data will be stored on. in this case the only answer to expect is z, which is a ack.
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 283 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by tstampRST().

Here is the call graph for this function:

int kh3_revision ( char *  outbuf,
knet_dev_t hDev 
)

kh3_revision retrieves the current OS version/revision

Parameters:
outbuf is a buffer where the data will be stored on.
hDev is a handle to an openned knet socket (Khepera3:dsPic).
Returns:
A value:
  • <0 on error
  • >=0 on success (returns should be the size of frame)

Definition at line 319 of file kb_khepera3.c.

References K3_CMD_DELAY, kb_gpio_get(), kh3_getcommand(), kh3_sendcommand(), and KNET_INT0.

Referenced by main(), and revisionOS().

Here is the call graph for this function:

int kh3_sendcommand ( knet_dev_t hDev,
unsigned char *  in 
)

kh3_sendcommand sets a command frame to a given khepera3 device.

Normally and end user don't want to use these function as they are assumed as "low level functions".

Parameters:
hDev is a handle to an openned knet socket (Khepera3:dsPic).
in is a pointer to a buffer where the command frame to be sent is stored on.
Returns:
A value:
  • <0 on error (KH3_ERROR_FRMSNDERR)
  • >=0 on success (returns should be the size of frame)
Remarks:
This function requires that kb_kh3_init has been called

Definition at line 138 of file kb_khepera3.c.

References KB_ERROR, KB_ERROR_KH3FRMSNDERR, KH3_ERROR_FRMSND, and knet_llwrite().

Referenced by braitenberg(), braitenbergAvoidance(), kh3_ambiant_ir(), kh3_battery_voltage(), kh3_configure_os(), kh3_measure_us(), kh3_proximity_ir(), kh3_reset_tstamp(), kh3_revision(), and SetLED().

Here is the call graph for this function:


Variable Documentation

double kh3_mms_to_speed = MM_S_TO_SPEED_FIRMWARE_S_3

Definition at line 30 of file kb_khepera3.c.

Referenced by main().

double kh3_pulses_to_mm = PULSE_TO_MM_FIRMWARE_S_3

Definition at line 29 of file kb_khepera3.c.

Generated on Mon Dec 3 09:43:48 2012 for KoreBot Library by  doxygen 1.6.3