JM9 XRCU Board 0.1.2
Libraries API Reference
Loading...
Searching...
No Matches
Jason Class Reference

Jason Driver for XRCU. More...

#include <Jason.h>

Inheritance diagram for Jason:
Print

Public Member Functions

 Jason ()
 Creates a robot object.
 
 ~Jason ()
 Destroys a robot object.
 
void load_saved_info ()
 
void store_saved_info ()
 
void set_motor_port (const uint8_t mtr_idx, const uint8_t port)
 
uint8_t get_motor_port (const uint8_t mtr_idx)
 
void set_compoi_port (const uint8_t idx, const uint8_t port)
 
uint8_t get_compoi_port (const uint8_t idx)
 
void set_compoi_addr (const uint8_t idx, const uint8_t addr)
 
uint8_t get_compoi_addr (const uint8_t idx)
 
void set_uts_mode (const uint8_t side, const uint8_t mode)
 
uint8_t get_uts_mode (const uint8_t side)
 
void set_uts_port (const uint8_t side, const uint8_t port)
 
uint8_t get_uts_port (const uint8_t side)
 
void set_heading_port (const uint8_t port)
 
uint8_t get_heading_port ()
 
void set_heading_addr (const uint8_t addr)
 
uint8_t get_heading_addr ()
 
void set_cam_port (const uint8_t port)
 
uint8_t get_cam_port ()
 
void set_cam_baud (const uint32_t baud)
 
uint32_t get_cam_baud ()
 
void set_kicker_pin (const uint32_t pin)
 
uint32_t get_kicker_pin ()
 
void set_dribbler_pin (const uint32_t pin)
 
uint32_t get_dribbler_pin ()
 
void set_comm_port (const uint8_t port)
 
uint8_t get_comm_port ()
 
void set_comm_baud (const uint32_t baud)
 
uint32_t get_comm_baud ()
 
void begin ()
 Activates the robot and configure the peripherals.
 
void end ()
 Deactivates the robot and releases all occupied resources.
 
void set_motor_spd (const uint8_t mtr_idx, int16_t spd)
 Sets the speed of a motor.
 
void polar_ctrl (int16_t angle, int16_t spd, int16_t rotation)
 Sets the polar speed of the robot.
 
void rect_ctrl (int16_t spd_x, int16_t spd_y, int16_t rotation)
 Sets the rectangular (cartesian) speed of the robot.
 
bool move_to (const uint8_t side1, const int16_t dist1, const uint8_t side2, const int16_t dist2, const int16_t target_heading=0, const double rotation_kp=1.2, const int16_t spd=100, const int16_t threshold=1)
 Moves the robot to a specific position.
 
virtual void gs ()
 Do something about the grayscales.
 
int16_t get_ir_max_val ()
 Gets the maximum value read by all IR channels.
 
int16_t get_ir_avg_val ()
 Gets the average value read by all IR channels.
 
int8_t get_ir_max_idx ()
 Gets the channel number of the maximum valued IR channel.
 
int16_t get_ir_ball_angle ()
 Gets the IR ball angle (in degrees).
 
int16_t get_uts_dist (const uint8_t side)
 Gets the ultrasonic sensor distance of one side.
 
void disable_uts (const uint8_t side)
 Disables an ultrasonic sensor of one side.
 
void enable_uts (const uint8_t side)
 Enables an ultrasonic sensor of one side.
 
int16_t get_heading ()
 Gets the heading of the robot.
 
void reset_heading ()
 Resets the heading of the robot.
 
int16_t get_rotation_spd (const int16_t target_heading=0)
 Gets the rotation speed of the robot.
 
virtual int16_t get_orange_ball_dist ()
 Gets the distance to the orange ball.
 
virtual int16_t get_orange_ball_angle ()
 Gets the angle to the orange ball (in degrees).
 
virtual int16_t get_opponent_goal_dist ()
 Gets the distance to the opponent's goal.
 
virtual int16_t get_opponent_goal_angle ()
 Gets the angle to the opponent's goal (in degrees).
 
virtual int16_t get_my_goal_dist ()
 Gets the distance to my goal.
 
virtual int16_t get_my_goal_angle ()
 Gets the angle to my goal (in degrees).
 
virtual void set_kicker_state (const bool state)
 Sets whether the kicker is "kicked" (extended) or retracted.
 
virtual bool get_kicker_state ()
 Gets whether the kicker is "kicked" (extended) or retracted.
 
virtual void set_dribbler_spd (const int16_t spd)
 Sets the spinning speed of the dribbler.
 
void clear_mon ()
 Clears everything on the monitor.
 
void set_cursor (int16_t x, int16_t y)
 Sets the cursor to print text on the monitor.
 
size_t print (const __FlashStringHelper *)
 
size_t print (const String &)
 
size_t print (const char[])
 
size_t print (char)
 
size_t print (unsigned char, int=DEC)
 
size_t print (int, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t print (double, int=2)
 
size_t print (const Printable &)
 
size_t write (uint8_t)
 
- Public Member Functions inherited from Print
int getWriteError ()
 
void clearWriteError ()
 
size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
size_t write (const char *buffer, size_t size)
 
virtual int availableForWrite ()
 
size_t print (const __FlashStringHelper *)
 
size_t print (const String &)
 
size_t print (const char[])
 
size_t print (char)
 
size_t print (unsigned char, int=DEC)
 
size_t print (int, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (float, int=2)
 
size_t print (double, int=2)
 
size_t print (const Printable &)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const String &s)
 
size_t println (const char[])
 
size_t println (char)
 
size_t println (unsigned char, int=DEC)
 
size_t println (int, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (float, int=2)
 
size_t println (double, int=2)
 
size_t println (const Printable &)
 
size_t println (void)
 
int printf (const char *format,...)
 
int printf (const __FlashStringHelper *format,...)
 
int vprintf (const __FlashStringHelper *format, va_list ap)
 
int vprintf (const char *format, va_list ap)
 
virtual void flush ()
 

Protected Attributes

uint8_t eeprom_img [32]
 
Mtrmtrs [4]
 
CompoIcompois [2]
 
uts_aio_ptr_t utss [4]
 
heading_ptr_t heading
 
uart_conn_ptr_t cam
 
uint32_t kicker_pin
 
uint32_t dribbler_pin
 
uart_conn_ptr_t comm
 
uint16_t xc
 
uint16_t yc
 

Additional Inherited Members

- Protected Member Functions inherited from Print
void setWriteError (int err=1)
 

Detailed Description

Jason Driver for XRCU.

Author
YH Choi @ JM9

Member Function Documentation

◆ disable_uts()

void Jason::disable_uts ( const uint8_t side)

Disables an ultrasonic sensor of one side.

Parameters
sidethe side of ultrasonic sensor to be disabled [front, back, left, right]
See also
side_t

◆ enable_uts()

void Jason::enable_uts ( const uint8_t side)

Enables an ultrasonic sensor of one side.

Parameters
sidethe side of ultrasonic sensor to be enabled [front, back, left, right]
See also
side_t

◆ get_heading()

int16_t Jason::get_heading ( )

Gets the heading of the robot.

Returns
the heading of the robot [0 : 359]

◆ get_ir_avg_val()

int16_t Jason::get_ir_avg_val ( )

Gets the average value read by all IR channels.

Returns
the average value read by all IR channels [0 : 255]
See also
get_ir_max_val()
get_ir_max_idx()
get_ir_ball_angle()

◆ get_ir_ball_angle()

int16_t Jason::get_ir_ball_angle ( )

Gets the IR ball angle (in degrees).

Returns
the IR ball angle [0 : 359] (in degrees)
See also
get_ir_max_val()
get_ir_avg_val()
get_ir_max_idx()

◆ get_ir_max_idx()

int8_t Jason::get_ir_max_idx ( )

Gets the channel number of the maximum valued IR channel.

......................
..........01..........
.....12........02.....
..11..............03..
.10.......().......04.
..09..............05..
.....08........06.....
..........07..........
......................

Returns
the channel number of the maximum valued IR channel [1 : 12]
See also
get_ir_max_val()
get_ir_avg_val()
get_ir_ball_angle()

◆ get_ir_max_val()

int16_t Jason::get_ir_max_val ( )

Gets the maximum value read by all IR channels.

Returns
the maximum value read by all IR channels [0 : 255]
See also
get_ir_avg_val()
get_ir_max_idx()
get_ir_ball_angle()

◆ get_kicker_state()

bool Jason::get_kicker_state ( )
virtual

Gets whether the kicker is "kicked" (extended) or retracted.

Warning
This method is not implemented.
Returns
true if the kicker is extended, false if the kicker is retracted

◆ get_my_goal_angle()

int16_t Jason::get_my_goal_angle ( )
virtual

Gets the angle to my goal (in degrees).

Warning
This method is not implemented.
Returns
the angle to my goal (in degrees)

◆ get_my_goal_dist()

int16_t Jason::get_my_goal_dist ( )
virtual

Gets the distance to my goal.

Warning
This method is not implemented.
Returns
the distance to my goal

◆ get_opponent_goal_angle()

int16_t Jason::get_opponent_goal_angle ( )
virtual

Gets the angle to the opponent's goal (in degrees).

Warning
This method is not implemented.
Returns
the angle to the opponent's goal (in degrees)

◆ get_opponent_goal_dist()

int16_t Jason::get_opponent_goal_dist ( )
virtual

Gets the distance to the opponent's goal.

Warning
This method is not implemented.
Returns
the distance to the opponent's goal

◆ get_orange_ball_angle()

int16_t Jason::get_orange_ball_angle ( )
virtual

Gets the angle to the orange ball (in degrees).

Warning
This method is not implemented.
Returns
the angle to the orange ball (in degrees)

◆ get_orange_ball_dist()

int16_t Jason::get_orange_ball_dist ( )
virtual

Gets the distance to the orange ball.

Warning
This method is not implemented.
Returns
the distance to the orange ball

◆ get_rotation_spd()

int16_t Jason::get_rotation_spd ( const int16_t target_heading = 0)

Gets the rotation speed of the robot.

Gets the rotation speed of the robot based on the difference between targeted heading and actual heading of the robot.

Parameters
target_heading=0the targeted heading of the robot (-inf : +inf) (in degrees)
Returns
the rotation speed of the robot (based on the difference between targeted heading and actual heading of the robot) [-180 : +180]

◆ get_uts_dist()

int16_t Jason::get_uts_dist ( const uint8_t side)

Gets the ultrasonic sensor distance of one side.

Parameters
sidethe side of ultrasonic sensor to be read [front, back, left, right]
Returns
the distance read by the ultrasonic sensor at that side [0 : 400] (in centimeters)
See also
side_t

◆ gs()

void Jason::gs ( )
virtual

Do something about the grayscales.

I dig not implement anything at this stage, since I don't know you would use circular or cross grayscales.

◆ move_to()

bool Jason::move_to ( const uint8_t side1,
const int16_t dist1,
const uint8_t side2,
const int16_t dist2,
const int16_t target_heading = 0,
const double rotation_kp = 1.2,
const int16_t spd = 100,
const int16_t threshold = 1 )

Moves the robot to a specific position.

This is achieved by continuously measuring the distances of 2 perpendicular sides.

Parameters
side11 of the side [front, back, left, right]
dist1the targeted distance from side1 [0 : +inf)
side21 of the side [front, back, left, right]
dist2the targeted distance from side2 [0 : +inf)
target_heading=0the targeted heading of robot while moving (-inf : +inf) (in degrees)
rotation_kp=1.2the constant to be multiplied from heading difference to give the angular rotation speed for heading correction [0 : +inf)
spd=100the net speed the robot moves [0 : +255]
threshold=1the tolerance to stop the robot (robot is stopped on an axis when get_uts_dist(sideN) == distN ± threshold) [0 : +inf)
See also
polar_ctrl(int16_t,int16_t,int16_t)
rect_ctrl(int16_t,int16_t,int16_t)
get_uts_dist(uint8_t)
get_rotation_spd(int16_t)
side_t
Returns
true if the robot arrived the specified position, false otherwise

◆ polar_ctrl()

void Jason::polar_ctrl ( int16_t angle,
int16_t spd,
int16_t rotation )

Sets the polar speed of the robot.

Parameters
anglethe direction the robot moves (-inf : +inf) (in degrees)
spdthe net speed the robot moves [-255 : +255]
rotationthe angular rotation speed the robot moves
See also
set_motor_spd(uint8_t,int16_t)
rect_ctrl(int16_t,int16_t,int16_t)
move_to(uint8_t,int16_t,uint8_t,int16_t,int16_t,double,int16_t,int16_t)

◆ rect_ctrl()

void Jason::rect_ctrl ( int16_t spd_x,
int16_t spd_y,
int16_t rotation )

Sets the rectangular (cartesian) speed of the robot.

Parameters
spd_xthe horizontal speed the robot moves ((-) left | right (+)) [-255 : +255]
spd_ythe vertical speed the robot moves ((-) back | front (+)) [255 : +255]
rotationthe angular rotation speed the robot moves
See also
set_motor_spd(uint8_t,int16_t)
polar_ctrl(int16_t,int16_t,int16_t)
move_to(uint8_t,int16_t,uint8_t,int16_t,int16_t,double,int16_t,int16_t)

◆ reset_heading()

void Jason::reset_heading ( )

Resets the heading of the robot.

After calling this function, the current heading of the robot is set to 0.

◆ set_cursor()

void Jason::set_cursor ( int16_t x,
int16_t y )

Sets the cursor to print text on the monitor.

Parameters
xthe x-position of letter to be printed
ythe y-position of letter to be printed

◆ set_dribbler_spd()

void Jason::set_dribbler_spd ( const int16_t spd)
virtual

Sets the spinning speed of the dribbler.

Warning
This method is not implemented.
Parameters
spdthe speed of the dribbler.

◆ set_kicker_state()

void Jason::set_kicker_state ( const bool state)
virtual

Sets whether the kicker is "kicked" (extended) or retracted.

Warning
This method is not implemented.
Parameters
statetrue if the kicker is extended, false if the kicker is retracted

◆ set_motor_spd()

void Jason::set_motor_spd ( const uint8_t mtr_idx,
int16_t spd )

Sets the speed of a motor.

Parameters
mtr_idxthe index of the motor to be set [LF, RF, LB, RB]
spdthe new speed of the motor [-255 : +255]
See also
mtr_idx_t

◆ write()

size_t Jason::write ( uint8_t c)
virtual

Implements Print.


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