test_tools
Public Member Functions | Public Attributes | List of all members
test_tools.odometer.Odometer Class Reference

Public Member Functions

def __init__ (self, path=DEFAULT_PATH, filename=DEFAULT_FILENAME)
 
def activate_write (self, length)
 
def callback (self, msg)
 
def sample (self)
 
def shutdown (self)
 
def write (self)
 

Public Attributes

 data
 
 file_has_header
 
 last_pose
 
 last_time
 
 newfilepath
 
 total_distance
 
 total_rotation
 
 total_time
 

Detailed Description

Odometer logs odometry. The odometry is measured in a callback function and sampled to a data storage in sample().
The data is written to a csv file, which is appended with a date. This is done is write(). In shutdown(), sample() and
write() are called to prevent data lost. This function is called on rospy shutdown. You can activate periodic
writing by calling active_write() in a loop, which the maximum length of your data storage as argument.

Definition at line 22 of file src/test_tools/odometer.py.

Constructor & Destructor Documentation

◆ __init__()

def test_tools.odometer.Odometer.__init__ (   self,
  path = DEFAULT_PATH,
  filename = DEFAULT_FILENAME 
)
Constructor
In the constructor old data is retrieved, if possible. Otherwise it starts from zero.

:param path: Path to store the data. Path is expanded by hostname(lowercase). Can be relative or in home folder
:type path: str
:param filename: Filename of data file. Filenames are appended with date and extension.
:type filename: str

Definition at line 29 of file src/test_tools/odometer.py.

Member Function Documentation

◆ activate_write()

def test_tools.odometer.Odometer.activate_write (   self,
  length 
)
If self.data contains more than X samples, all the data is written to the file

:param length:
:type length: int
:return: no return

Definition at line 210 of file src/test_tools/odometer.py.

◆ callback()

def test_tools.odometer.Odometer.callback (   self,
  msg 
)
Measuring the displacement based on the new position

:param msg: Odometry msg with position and rotation information
:type msg: nag_msgs.msg.Odometry
:return: no return

Definition at line 173 of file src/test_tools/odometer.py.

◆ sample()

def test_tools.odometer.Odometer.sample (   self)
Current measurements are stored in self.data

:return: no return

Definition at line 129 of file src/test_tools/odometer.py.

◆ shutdown()

def test_tools.odometer.Odometer.shutdown (   self)
To prevent data loss between last sample and shutdown, this function is called to sample and write all the data.

:return: no return

Definition at line 221 of file src/test_tools/odometer.py.

◆ write()

def test_tools.odometer.Odometer.write (   self)
Writing all data in self.data to the data file and closing it again. This should prevent file corruption.

:return: no return

Definition at line 146 of file src/test_tools/odometer.py.

Member Data Documentation

◆ data

test_tools.odometer.Odometer.data

Definition at line 56 of file src/test_tools/odometer.py.

◆ file_has_header

test_tools.odometer.Odometer.file_has_header

Definition at line 50 of file src/test_tools/odometer.py.

◆ last_pose

test_tools.odometer.Odometer.last_pose

Definition at line 57 of file src/test_tools/odometer.py.

◆ last_time

test_tools.odometer.Odometer.last_time

Definition at line 58 of file src/test_tools/odometer.py.

◆ newfilepath

test_tools.odometer.Odometer.newfilepath

Definition at line 47 of file src/test_tools/odometer.py.

◆ total_distance

test_tools.odometer.Odometer.total_distance

Definition at line 53 of file src/test_tools/odometer.py.

◆ total_rotation

test_tools.odometer.Odometer.total_rotation

Definition at line 54 of file src/test_tools/odometer.py.

◆ total_time

test_tools.odometer.Odometer.total_time

Definition at line 52 of file src/test_tools/odometer.py.


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