Page 1 of 1

Understanding the new API changes

Posted: Mon Feb 03, 2014 5:33 pm
by doddz
Hi all,

I've been trying to understand the new changes to the logging API so I've been going through the API documentation code and changing it over line by line where needed. I've got this piece of code that seems to compile okay but when the execution reaches the logging section it craps out with this.

Code: Select all

  File "/home/bitcraze/projects/crazyflie-pc-client/lib/cfaltlogger.py", line 46, in connectSetupFinished
    self.accel_log = self.crazyflie.log.add_config(accel_log_conf)
  File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/log.py", line 413, in add_config
    var.name) is None):
  File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/toc.py", line 90, in get_element_by_complete_name
    return self.get_element_by_id(self.get_element_id(complete_name))
  File "/home/bitcraze/projects/crazyflie-pc-client/lib/cflib/crazyflie/toc.py", line 98, in get_element_id
    [group, name] = complete_name.split(".")

Cheers,
doddz

Does anyone know if the crazyflie.log.add_config(accel_log_conf) was the right method to call? Has anyone had this error too and figured out what it was?


The code in question...

Code: Select all

        # Set accelerometer logging config
        accel_log_conf = LogConfig("Accel", 10)
        accel_log_conf.add_variable(LogVariable("acc.x", "float"))
        accel_log_conf.add_variable(LogVariable("acc.y", "float"))
        accel_log_conf.add_variable(LogVariable("acc.z", "float"))

        # Now that the connection is established, start logging
        self.accel_log = self.crazyflie.log.add_config(accel_log_conf)

        if self.accel_log is not None:
            self.accel_log.data_received_cb.add_callback(self.log_accel_data)
            self.accel_log.start()
        else:
            print("acc.x/y/z not found in log TOC")

    def log_accel_data(self, data):
        logging.info("Accelerometer: x=%.2f, y=%.2f, z=%.2f" %
                        (data["acc.x"], data["acc.y"], data["acc.z"]))

Re: Understanding the new API changes

Posted: Tue Feb 04, 2014 10:18 am
by marcus
Hi,

The new release 2014.01 contains examples on how to use the logging (in the examples directory). The wiki page has also been updated with the changes, but it's still being worked on. Here's a direct link to the examples directory on BitBucket.

If there's anything missing in the examples or on the update wiki page let us know and we will add it.

/Marcus

Re: Understanding the new API changes

Posted: Tue Feb 11, 2014 9:41 am
by doddz
Thanks Marcus, the examples and updated wiki are really helpful.

Sent from my HTC One using Tapatalk