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

Committer:
giovanniberi93
Date:
Fri May 11 08:04:59 2018 +0000
Revision:
13:04fa45b2bee1
Parent:
6:e96e9bb1a7cc
No significant changes, commit only to publish the project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
giovanniberi93 2:2d6a1a09c59f 1 // This section includes the parameters that the users might want to modify or set
giovanniberi93 2:2d6a1a09c59f 2
giovanniberi93 3:8a744d554a2f 3 #define DEVICE_IP "192.168.1.11"
giovanniberi93 3:8a744d554a2f 4 #define PC_IP "192.168.1.45"
giovanniberi93 3:8a744d554a2f 5
giovanniberi93 3:8a744d554a2f 6 #define RECEIVE_PORT 100
giovanniberi93 6:e96e9bb1a7cc 7 #define DESTINATION_PORT 7878
giovanniberi93 3:8a744d554a2f 8
giovanniberi93 3:8a744d554a2f 9 #define UDP_SEND_PACKET_SIZE 350
giovanniberi93 3:8a744d554a2f 10 #define UDP_RECEIVE_PACKET_SIZE 350
giovanniberi93 2:2d6a1a09c59f 11
giovanniberi93 5:930185bdb68f 12 #define SERIAL_BAUD 115200
giovanniberi93 5:930185bdb68f 13
giovanniberi93 2:2d6a1a09c59f 14
giovanniberi93 2:2d6a1a09c59f 15 ////////////////////////////////////////////////////////
giovanniberi93 2:2d6a1a09c59f 16
giovanniberi93 2:2d6a1a09c59f 17 #define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
giovanniberi93 2:2d6a1a09c59f 18 #define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
giovanniberi93 2:2d6a1a09c59f 19 #define HTTP_MESSAGE_BODY "" \
giovanniberi93 2:2d6a1a09c59f 20 "<html>" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 21 " <body style=\"display:flex;text-align:center\">" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 22 " <div style=\"margin:auto\">" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 23 " <h1>Hello World</h1>" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 24 " <p>It works !</p>" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 25 " </div>" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 26 " </body>" "\r\n" \
giovanniberi93 2:2d6a1a09c59f 27 "</html>"
giovanniberi93 2:2d6a1a09c59f 28
giovanniberi93 2:2d6a1a09c59f 29 #define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \
giovanniberi93 2:2d6a1a09c59f 30 HTTP_HEADER_FIELDS "\r\n" \
giovanniberi93 2:2d6a1a09c59f 31 "\r\n" \
giovanniberi93 2:2d6a1a09c59f 32 HTTP_MESSAGE_BODY "\r\n"
giovanniberi93 2:2d6a1a09c59f 33
giovanniberi93 2:2d6a1a09c59f 34
giovanniberi93 2:2d6a1a09c59f 35 // Check IP packages compatibility
giovanniberi93 2:2d6a1a09c59f 36 #if !FEATURE_LWIP
giovanniberi93 2:2d6a1a09c59f 37 #error [NOT_SUPPORTED] LWIP not supported for this target
giovanniberi93 2:2d6a1a09c59f 38 #endif