Modules | Enumerations
Remote control

Functions which handle the remote control. More...

Modules

 Advanced informations
 

Enumerations

enum  eRemoteControlSelectMask
 clusters bit masks for the requests of the remote control More...
 
enum  eRemoteControlGet
 clusters select values for reading data from the remote control More...
 

Request Funktions

void remoteControl_request (eRemoteControlSelectMask bitmask, eRequestType request)
 Requests new data from the remote control. More...
 
eRemoteControlSelectMask remoteControl_received (eRemoteControlSelectMask bitmask)
 Indicates if new data for the selected data blocks were received. More...
 
eRemoteControlSelectMask remoteControl_changed (eRemoteControlSelectMask bitmask)
 Indicates if new data changed the selected data blocks. More...
 

Access Funktions

int16_t remoteControl_get (eRemoteControlGet select)
 Returns the last stored version of the selected value. More...
 

Detailed Description

Functions which handle the remote control.

For sending and receiving data on the PC, there exists a ROS module. However, a simplified Python counterpart to the TUC-Bot example is given here - it can be used to test the connection to the robot:
remoteControl.py and packedCom.py

example

/*******************************************************************************
* examples/remoteControl.c *
* ======================== *
* *
* Version: 1.0.7 *
* Date : 14.02.18 *
* Author : Peter Weissig *
* *
* If you are changing this file, you may also consider to update *
* demos/diagnosticTool/diagnosticTool.c *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
#include <tucbot_additionals/packedCom.h>
#include <tucbot_additionals/remoteControl.h>
//*********************************<Methods>************************************
void testRemoteControl(void);
int main(void);
//*********************************[testRemoteControl]**************************
void testRemoteControl(void) {
uint8_t menu_pos = 0;
uint8_t flag_redraw_menu = 0xFF;
uint8_t value_active = 0xFF;
uint8_t value_count = 0;
uint8_t temp;
lcdclr();
lcdstr_p(PSTR("Remote ctrl ###"));
while (1) {
// redraw menu
if (flag_redraw_menu) {
flag_redraw_menu = 0x00;
lcdxy(0,1);
if (menu_pos == 0) {
lcdstr_p(PSTR("l=####%, r=####%"));
} else {
lcdstr_p(PSTR("a=#####, v=#####"));
}
mdelay(400);
}
// check if buttons were pushed
// middle button --> toggle menu
mdelay(100);
if (menu_pos == 0) {
menu_pos = 1;
mdelay(100);
} else {
menu_pos = 0;
#ifdef TUCBOT_PUPIL
#endif // #ifdef TUCBOT_PUPIL
mdelay(100);
}
flag_redraw_menu = 0xFF;
} else if (buttons_get(kButtonRight)) {
// right button --> toggle packed communication (on/off)
mdelay(100);
lcdxy(11,0);
if (value_active) {
lcdout('#');
value_active = 0x00;
if (menu_pos == 1) {
#ifdef TUCBOT_PUPIL
#endif // #ifdef TUCBOT_PUPIL
}
} else {
lcdout(' ');
value_active = 0xFF;
}
}
// update display (general)
if (temp != value_count) {
value_count = temp;
lcdxy(13,0); uint16tostr(lcdout,temp,3);
}
// update display depending on menu position
if (menu_pos == 0) {
lcdxy( 2,1);
lcdxy(11,1);
if (value_active) {
cli();
sei();
}
}
} else {
lcdxy( 2,1);
lcdxy(11,1);
if (value_active) {
#ifdef TUCBOT_PUPIL
#endif // #ifdef TUCBOT_PUPIL
}
}
}
mdelay(100);
// signal user if robot is controlled by velocites, but is programmed
// in student mode
#ifndef TUCBOT_PUPIL
if (value_active && menu_pos) {
}
#endif // #ifdef TUCBOT_PUPIL
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testRemoteControl();
return (0);
}

Enumeration Type Documentation

◆ eRemoteControlGet

clusters select values for reading data from the remote control

See also
remoteControl_get()
Enumerator
kRemoteControlGetMotorLeft 

constant (1): left motor power in percent (8-bit)

kRemoteControlGetMotorRight 

constant (2): right motor power in percent (8-bit)

kRemoteControlGetTwistLinear 

constant (3): linear speed in mm/s (16-bit)

kRemoteControlGetTwistAngular 

constant (4): angular speed in degrees/s (16-bit)

◆ eRemoteControlSelectMask

clusters bit masks for the requests of the remote control

See also
remoteControl_request(), remoteControl_received() and remoteControl_changed()
Enumerator
kRemoteControlSelectNone 

bit mask (0x00): select no data block

kRemoteControlSelectTwist 

bit mask (0x01): select twist message
see also sRemoteControlTwist

kRemoteControlSelectMotor 

bit mask (0x02): select motor commands
see also sRemoteControlMotor

kRemoteControlSelectAll 

bit mask (0x03): select all data blocks

Function Documentation

◆ remoteControl_changed()

eRemoteControlSelectMask remoteControl_changed ( eRemoteControlSelectMask  bitmask)

Indicates if new data changed the selected data blocks.

Parameters
bitmaskbit mask of the selected data blocks - see also eRemoteControlSelectMask
The parameter is used to only return the value of the masked changed-bits. All other values(bits) are set to 0.
Returns
bitfield of the selected data blocks - see also eRemoteControlSelectMask
If a data block is changed its related bit will be 1, otherwise 0.
If only one data block is selected the return value can be interpreted as a boolean expression.
See also
remoteControl_received(), remoteControl_request() and remoteControl_get()
Examples
remoteControl.c.

◆ remoteControl_get()

int16_t remoteControl_get ( eRemoteControlGet  select)

Returns the last stored version of the selected value.

This function relies on the internal data blocks sRemoteControlTwist and sRemoteControlMotor - for new data use remoteControl_request().

Parameters
selectvalue of the selected data - see also eRemoteControlGet
Returns
16-bit integer
select description result
kRemoteControlGetTwistLinear linear speed in mm/s 16-bit
kRemoteControlGetTwistAngular angular speed in degrees/s 16-bit
kRemoteControlGetMotorLeft
kRemoteControlGetMotorRight
motor speed in percent 8-bit
See also
remoteControl_request()
Examples
remoteControl.c.

◆ remoteControl_received()

eRemoteControlSelectMask remoteControl_received ( eRemoteControlSelectMask  bitmask)

Indicates if new data for the selected data blocks were received.

Parameters
bitmaskbit mask of the selected data blocks - see also eRemoteControlSelectMask
The parameter is used to only return the value of the masked received-bits. All other values(bits) are set to 0.
Returns
bitfield of the selected data blocks - see also eRemoteControlSelectMask
If a data block is received its related bit will be 1, otherwise 0.
If only one data block is selected the return value can be interpreted as a boolean expression.
See also
remoteControl_changed(), remoteControl_request() and remoteControl_get()

◆ remoteControl_request()

void remoteControl_request ( eRemoteControlSelectMask  bitmask,
eRequestType  request 
)

Requests new data from the remote control.

For details on the request schema see The general request.

Involved data blocks are:
sRemoteControlTwist and sRemoteControlMotor

Parameters
bitmaskbit mask of the selected data blocks - see also eRemoteControlSelectMask
requestSee also eRequestType
See also
remoteControl_get()
Examples
remoteControl.c.
leds_set
void leds_set(eLedMask bitmask, uint8_t bool)
Sets the selected leds on or off.
buttons_get
eButtonMask buttons_get(eButtonMask bitmask)
Returns the last stored value of the selected buttons.
kButtonMiddle
@ kButtonMiddle
bit mask (0x08): middle button
Definition: buttons.h:35
kRemoteControlGetMotorRight
@ kRemoteControlGetMotorRight
constant (2): right motor power in percent (8-bit)
Definition: remoteControl.h:126
kModeStudent
@ kModeStudent
constant (1): robot is in student mode
Definition: mode.h:31
remoteControl_get
int16_t remoteControl_get(eRemoteControlGet select)
Returns the last stored version of the selected value.
kMotorSetAll
@ kMotorSetAll
bit mask (0x03): both motors
Definition: motors.h:47
kMotorSetRight
@ kMotorSetRight
bit mask (0x02): right motor
Definition: motors.h:45
kLedOn
@ kLedOn
constant (0xFF): turn leds on
Definition: leds.h:63
kLedRight
@ kLedRight
bit mask (0x04): right led
Definition: leds.h:46
kRemoteControlSelectAll
@ kRemoteControlSelectAll
bit mask (0x03): select all data blocks
Definition: remoteControl.h:114
kModePupil
@ kModePupil
constant (0): robot is in pupil mode
Definition: mode.h:29
kRemoteControlSelectMotor
@ kRemoteControlSelectMotor
Definition: remoteControl.h:111
kButtonRight
@ kButtonRight
bit mask (0x10): right button
Definition: buttons.h:37
buttons_request
void buttons_request(eRequestType request)
Requests new data from the buttons.
int16tostr
void int16tostr(void *out, int16_t number, uint8_t digits)
Converts an integer to a string and passes it to an output function.
kRemoteControlSelectTwist
@ kRemoteControlSelectTwist
Definition: remoteControl.h:108
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kLedMiddle
@ kLedMiddle
bit mask (0x08): middle led
Definition: leds.h:44
kLedOff
@ kLedOff
constant (0x00): turn leds off
Definition: leds.h:61
uint16tostr
void uint16tostr(void *out, uint16_t number, uint8_t digits)
Converts an unsigned integer to a string and passes it to an output function.
packedCom_activate
void packedCom_activate(void)
Turns the reception of data packets on.
lcdclr
void lcdclr(void)
Clears the display.
remoteControl_changed
eRemoteControlSelectMask remoteControl_changed(eRemoteControlSelectMask bitmask)
Indicates if new data changed the selected data blocks.
packedCom_get
uint8_t packedCom_get(ePackedComGet select)
Returns the last stored selected value.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
mode_set
void mode_set(eMode mode)
Sets the mode of the TUC-Bot.
drive_stop
void drive_stop(eDriveStop mode)
Lets the robot stop driving.
motors_set
void motors_set(eMotorSetMask select, int8_t power)
Sets the motor power of the selected motor(s).
kPackedComGetPacketCount
@ kPackedComGetPacketCount
constants (2): number of correct received packets
Definition: packedCom.h:264
kDriveStopNormal
@ kDriveStopNormal
constant (0): continuously decreasing the speed
Definition: drive.h:31
remoteControl_request
void remoteControl_request(eRemoteControlSelectMask bitmask, eRequestType request)
Requests new data from the remote control.
lcdstr_p
void lcdstr_p(const char *send_data)
Writes a string located in the flash to the display.
kMotorSetLeft
@ kMotorSetLeft
bit mask (0x01): left motor
Definition: motors.h:43
lcdout
void lcdout(uint8_t data)
Writes one byte to the display.
init_tucbot
void init_tucbot(uint8_t enable_interrupts)
Initiates the TUC-Bot.
mdelay
void mdelay(uint16_t mseconds)
Waits for the given time in milliseconds.
kRemoteControlGetTwistLinear
@ kRemoteControlGetTwistLinear
constant (3): linear speed in mm/s (16-bit)
Definition: remoteControl.h:128
drive_adjust
void drive_adjust(int16_t speed_distance, int16_t speed_angle)
Adjusts the robots driving.
kRemoteControlGetMotorLeft
@ kRemoteControlGetMotorLeft
constant (1): left motor power in percent (8-bit)
Definition: remoteControl.h:124
kRemoteControlGetTwistAngular
@ kRemoteControlGetTwistAngular
constant (4): angular speed in degrees/s (16-bit)
Definition: remoteControl.h:130
leds_get
eLedMask leds_get(eLedMask bitmask)
Returns the current state of the selected leds.