Skip to content

Commit

Permalink
New communication system (#49)
Browse files Browse the repository at this point in the history
* synchronous communication, remove protobuf

* accumulate ticks to send

* receive config parameters at startup, close #13

* file cleanup

* README.md

* fix ticks type
  • Loading branch information
fdila authored Aug 10, 2021
1 parent 3aa58a3 commit b15e5ef
Show file tree
Hide file tree
Showing 173 changed files with 12,398 additions and 113,514 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Otto
Material regarding my stage with Iralab, designing and realizing a 2 wheeled robot.

If you just want to use the program you can download the binary file from the [releases](https://github.com/iralabdisco/otto/releases):
If you just want to use the robot you can download the binary file from the [releases](https://github.com/iralabdisco/otto/releases):
1. Download the lastest otto_controller.bin
2. Plug your Nucleo boart to the PC.
3. Copy and paste the .bin file inside your board.

The main program is located in [otto_controller](https://github.com/iralabdisco/otto/tree/master/otto_controller).

You can find various useful tools inside the [utils](https://github.com/iralabdisco/otto/tree/master/utils) folder.

See the [wiki](https://github.com/iralabdisco/otto/wiki) for more info about this projects.

## Coding style
Follow [Google C++ guideline](https://google.github.io/styleguide/cppguide.html) while working on the project

Eclipse's formatting configuration file can be found [here](https://github.com/google/styleguide/blob/gh-pages/eclipse-cpp-google-style.xml)
Expand Down
35 changes: 19 additions & 16 deletions otto_controller/.cproject

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions otto_controller/.mxproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions otto_controller/.project
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>
6 changes: 3 additions & 3 deletions otto_controller/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-977709318318761742" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1141965905428366138" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -18,10 +18,10 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-977709318318761742" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1127776546690919898" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>
</project>
20 changes: 19 additions & 1 deletion otto_controller/.settings/org.eclipse.cdt.codan.core.prefs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions otto_controller/.settings/org.eclipse.cdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doxygen/doxygen_new_line_after_brief=true
doxygen/doxygen_use_brief_tag=false
doxygen/doxygen_use_javadoc_tags=true
doxygen/doxygen_use_pre_tag=false
doxygen/doxygen_use_structural_commands=false
eclipse.preferences.version=1
3 changes: 3 additions & 0 deletions otto_controller/.settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
8DF89ED150041C4CBC7CB9A9CAA90856=AE0564D014D0FF6F8CDA67667BE5E95D
DC22A860405A8BF2F2C095E5B6529F12=AE0564D014D0FF6F8CDA67667BE5E95D
eclipse.preferences.version=1
50 changes: 50 additions & 0 deletions otto_controller/Core/Inc/communication/otto_messages.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* otto_messages.h
*
* Created on: Aug 5, 2021
* Author: fdila
*/

#ifndef INC_COMMUNICATION_OTTO_MESSAGES_H_
#define INC_COMMUNICATION_OTTO_MESSAGES_H_

typedef struct _ConfigMessage {
uint32_t ticks_per_revolution; //x4 resolution
float baseline; //in meters
float left_wheel_circumference; //in meters
float right_wheel_circumference; //in meters
float kp_left;
float ki_left;
float kd_left;
float kp_right;
float ki_right;
float kd_right;
float kp_cross;
float ki_cross;
float kd_cross;
uint32_t crc;
} ConfigMessage;

typedef struct _VelocityMessage {
float linear_velocity;
float angular_velocity;
uint32_t crc;
} VelocityMessage;

typedef struct _StatusMessage {
/*
* Status codes:
* 0 - waiting for config
* 1 - running
* 2 - error receiving config
* 3 - error receiving vel
* 4 - H-Bridge fault
*/
uint16_t status;
uint16_t delta_millis;
int32_t left_ticks;
int32_t right_ticks;
uint32_t crc;
} StatusMessage;

#endif /* INC_COMMUNICATION_OTTO_MESSAGES_H_ */
16 changes: 15 additions & 1 deletion otto_controller/Core/Inc/control/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ class Pid {
int max_;

public:
Pid() {
this->kp_ = 0;
this->ki_ = 0;
this->kd_ = 0;

this->error_ = 0;
this->setpoint_ = 0;

this->previous_error_ = 0;
this->error_sum_ = 0;

this->min_ = 0;
this->max_ = 0;
}
Pid(float kp, float ki, float kd, int min, int max) {
this->kp_ = kp;
this->ki_ = ki;
Expand Down Expand Up @@ -78,7 +92,7 @@ class Pid {
if (integer_output > this->max_) {
integer_output = this->max_;
this->error_sum_ -= this->error_;
} else if (integer_output < this->min_){
} else if (integer_output < this->min_) {
integer_output = this->min_;
this->error_sum_ -= this->error_;
}
Expand Down
52 changes: 52 additions & 0 deletions otto_controller/Core/Inc/crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
******************************************************************************
* @file crc.h
* @brief This file contains all the function prototypes for
* the crc.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CRC_H__
#define __CRC_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern CRC_HandleTypeDef hcrc;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_CRC_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __CRC_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
20 changes: 8 additions & 12 deletions otto_controller/Core/Inc/dma.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
******************************************************************************
* File Name : dma.h
* Description : This file contains all the function prototypes for
* the dma.c file
* @file dma.h
* @brief This file contains all the function prototypes for
* the dma.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
Expand All @@ -17,11 +17,11 @@
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __dma_H
#define __dma_H
#ifndef __DMA_H__
#define __DMA_H__

#ifdef __cplusplus
extern "C" {
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
Expand All @@ -47,10 +47,6 @@ void MX_DMA_Init(void);
}
#endif

#endif /* __dma_H */

/**
* @}
*/
#endif /* __DMA_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
26 changes: 9 additions & 17 deletions otto_controller/Core/Inc/gpio.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
******************************************************************************
* File Name : gpio.h
* Description : This file contains all the functions prototypes for
* the gpio
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
Expand All @@ -16,12 +16,12 @@
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __gpio_H
#define __gpio_H
#ifndef __GPIO_H__
#define __GPIO_H__

#ifdef __cplusplus
extern "C" {
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
Expand All @@ -44,14 +44,6 @@ void MX_GPIO_Init(void);
#ifdef __cplusplus
}
#endif
#endif /*__ pinoutConfig_H */

/**
* @}
*/

/**
* @}
*/
#endif /*__ GPIO_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Loading

0 comments on commit b15e5ef

Please sign in to comment.