Sunday, 14 February 2016

Sprint one reflections by Filipe Terra

The first sprint aim was to setup a basic configuration for the Lampbotics robot. This involved the completion of tasks related to face detection, servo movements, sound playback and treading.

Our team decided to split the tasks between the four members and then join all the parts together when the individual tasks were completed.

My task was to setup the servos movement. I chose to use a separate board, XMOS based, to handle this. The goal was to use it as a motion algorithm co-processor, associated with the Raspberry Pi.

The Raspberry would send commands describing the desired motion to the XMOS board using SPI bus and the board would execute it, reporting to the RPi when needed. As an example of the motion request, it could contain the final position, time to execute the motion from the past position and an indication of the desired smoothing algorithm (multiple could be implemented).

The completion of this task, however, requires coding in both RPi and XMOS boards. Although the XMOS board contains a compatible connector to interface with the RPi GPIO, no specific libraries are provided by the XMOS developing tools for this task. Luckily, a third party sample project, involving basic servo control was found (described in my previous post). It uses the XMOS standard SPI slave library and implements a protocol for the communication between boards (Tag Length Value message). This very same protocol could be adapted for my needs.

Implementing a protocol is essential because the SPI interface alone is not capable of handling a large amount of data (the received bytes are stored in buffers, therefore we need means to evaluate their meaning).

The sample project provided a C# code for the RPi. We, however, intend to use Python due to its flexibility and easy coding. My first task was to get both boards communicating using Python on the RPi side. In this very first moment, the XMOS code of the sample project was not modified (its capable of setting the PWM ratio of up to 8 servos via a single SPI TLV message), so all the work was focused on emulating the same behavior of the C# code, but using Python. This task was completed successfully, but many issues were found in the process:

  • The first ribbon cable used to connect boards was faulty and required another one to be build.
  • The XMOS board is not capable of delivering power to the servos (another power source is needed).
  • The SPI bus is shared with the XMOS Flash memory, so when its being read in the power-up, strange behaviors are observed. Sometimes the Flash memory corrupts too.
  • The SPI interface does not seem to be terminated by the RPi when the Python script is closed.
Most of the work consisted of discovering the the SPI-dev (SPI Python library) parameters that work. They are describes in the end of my previous post. Getting to understand the XMOS .xc code was also difficult since I had no previous experience with this language and the code was extensive. I´m now testing modifications on it to implement movement smoothing and a movement stack, so that multiple movements could be send at once (still not successful).

This first part proved to be more challenging than I expected. I lost a great deal of time to discover that the XMOS board was sensitive to power supply noise. I´m also more aware that the motion algorithm needs for this project are not great as I first expected and I should focus more on helping my team with their motion needs (which are basic). I should also try to involve my teammates with my XMOS work, especially Lee, who could help me with the treading and integration with the other parts.

David had a great idea to have another XMOS board; this would allow them to have more contact with it as I take the single board we have home most of times. I´m sure they could also help me code the XMOS in the future. The overall teamwork experience was great; David was very helpful to help me setup the hardware and Philip´s RPi experience sorts out most problems in this part.

For the next sprint I´m hoping to finish my motion smoothing algorithm, implement a movement stack and maybe a movement log. I will also like to develop a separate board to power the servos (with current protection) and enable function so that the RPi can turn off the servos independently of the XMOS board. 

Filipe Terra post #3
Pi Over Four

No comments:

Post a Comment