The firmware for robì Nucleo board, used to read data from the IMU, send velocities commands to the wheels, and read actual wheel velocities.

Dependencies:   X_NUCLEO_IKS01A1

Robì board


Firmware overview

The goals of this firmware are:

  • read data from the IMU (the blue shield installed on the ), and send them through ethernet to the PC mounted on Robì
  • receive via ethernet the target velocity of the robot, calculate the required wheels velocities, and send them to the 4 wheels via CAN
  • receive via CAN the actual speeds of the wheels, calculate from them the actual robot velocities, and send it to the PC via ethernet.

For sending and receiving data through ethernet, on the board two UDP sockets are opened, one for outbound communication, and one for inbound communication. A serial communication is also set, that communicates with the PC through the same micro USB cable used to power the Nucleo board, and only trasmits debug info.
The only files you should need to edit/read are main.cpp, with the business logic, and param_config.h file, where you can consult or edit some firmware settings: IP&port for the UDP sockets, size of UDP packet, baudrate of the serial port.

Board setup

The blue shield with the IMU (X-NUCLEO-IKS01A1) must be placed in the connector on the board, the ethernet cable connected to the PC, the micro USB connected to the PC for power supply and debug. NOTE: two micro USB connectors exist, the correct one is the one on the opposite side of the board with respect to the ethernet connector, and not the one adjacent the ethernet connector.

On desktop side, the communication with the board is executed via ROS nodes, that you can find in this repo.

Actual functionalities

This firmware is still very raw, since I only had time to take steps for the implementation of the communication, and not on the logic. As a suggestion, read carefully the current code (it's only 140 LOC), and use it as an example of how the involved parts are going to communicate, rather than a simplified version of the final firmware.

Some final notes

  • learn the structure of the CAN messages to understand the prepareCANMessages procedure
  • for CAN communication you need to connect a CAN transceiver to PD0 and PD1 pins (make reference to this image)
  • the board currently sends raw data from the IMU, and the correction of the IMU bias/distortion is made in the ROS node that receive the data.

Jånzo

param_config.h

Committer:
giovanniberi93
Date:
2018-05-11
Revision:
13:04fa45b2bee1
Parent:
6:e96e9bb1a7cc

File content as of revision 13:04fa45b2bee1:

// This section includes the parameters that the users might want to modify or set

#define DEVICE_IP  "192.168.1.11"
#define PC_IP      "192.168.1.45"

#define RECEIVE_PORT      100
#define DESTINATION_PORT  7878

#define UDP_SEND_PACKET_SIZE     350
#define UDP_RECEIVE_PACKET_SIZE  350

#define SERIAL_BAUD 115200


////////////////////////////////////////////////////////

#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
#define HTTP_MESSAGE_BODY ""                                     \
"<html>" "\r\n"                                                  \
"  <body style=\"display:flex;text-align:center\">" "\r\n"       \
"    <div style=\"margin:auto\">" "\r\n"                         \
"      <h1>Hello World</h1>" "\r\n"                              \
"      <p>It works !</p>" "\r\n"                                 \
"    </div>" "\r\n"                                              \
"  </body>" "\r\n"                                               \
"</html>"

#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n"   \
                      HTTP_HEADER_FIELDS "\r\n" \
                      "\r\n"                    \
                      HTTP_MESSAGE_BODY "\r\n"
                      
                   
// Check IP packages compatibility
#if !FEATURE_LWIP
    #error [NOT_SUPPORTED] LWIP not supported for this target
#endif