Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor fusion Pull Request #23

Merged
merged 22 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
needs: intro
strategy:
matrix:
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget"]
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "SensorFusionTarget"]

# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
needs: intro
strategy:
matrix:
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "Test"]
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "Test", "SensorFusionTarget"]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
needs: intro
strategy:
matrix:
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "ConvoyLeaderSim", "LineFollowerSim", "RemoteControlSim"]
environment: ["ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "SensorFusionTarget", "ConvoyLeaderSim", "LineFollowerSim", "RemoteControlSim", "SensorFusionSim"]

steps:
- name: Checkout repository
Expand Down
72 changes: 72 additions & 0 deletions doc/architecture/SENSORFUSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Radon Ulzer - SENSORFUSION <!-- omit in toc -->

* [General](#general)
* [SerialMuxProt Channels](#serialmuxprot-channels)
* [Tx channel "LINE\_SENS"](#tx-channel-sensor_data)
* [SW Architecture](#sw-architecture)
* [Logical View](#logical-view)
* [Application](#application)
* [Abbreviations](#abbreviations)
* [Issues, Ideas And Bugs](#issues-ideas-and-bugs)
* [License](#license)
* [Contribution](#contribution)

# General

The robot sends sensor data (Odometry data and IMU data) via SerialMuxProt.

On target the physical communication uses the serial.

On simulation the physical communication uses a socket connection.

## SerialMuxProt Channels


### Tx channel "SENSOR_DATA"
This channel is used to send raw sensor data used for Sensor Fusion on the ZumoComSystem.

* The datatypes can be found in SerialMuxChannel.h.
* Order:
* Acceleration in X (raw sensor value)
* Acceleration in Y (raw sensor value)
* turnRateZ around Z (raw sensor value)
* Magnetometer value in X (raw sensor value)
* Magnetometer value in Y (raw sensor value)
* Angle calculated by Odometry (in mrad)
* Position in X calculated by Odometry (in mm)
* Position in Y calculated by Odometry (in mm)
* Endianess: Big endian

# SW Architecture
The following part contains the specific details of the SensorFusion application.

## Logical View

### Application
The application uses the same [State Machine](https://github.com/BlueAndi/RadonUlzer/blob/main/doc/architecture/LINEFOLLOWER.md) as the Line Follower Application.

### HAL
Some changes have been made to the HAL.
![HALSensorFusion](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/BlueAndi/RadonUlzer/SensorFusion/doc/architecture/uml/LogicalView/SensorFusion/HAL_SensorFusion.puml)

ButtonB, ButtonC, the ProximitySensor and the Buzzer have been removed.
An IMU has been added:
![HALIMU](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/BlueAndi/RadonUlzer/SensorFusion/doc/architecture/uml/LogicalView/SensorFusion/HAL_IMU.puml)

# Abbreviations

| Abbreviation | Description |
| - | - |
| HAL | Hardware Abstraction Layer |
| IMU | Inertial Measurement Unit |

# Issues, Ideas And Bugs
If you have further ideas or you found some bugs, great! Create a [issue](https://github.com/BlueAndi/RadonUlzer/issues) or if you are able and willing to fix it by yourself, clone the repository and create a pull request.

# License
The whole source code is published under the [MIT license](http://choosealicense.com/licenses/mit/).
Consider the different licenses of the used third party libraries too!

# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any
additional terms or conditions.
139 changes: 139 additions & 0 deletions doc/architecture/uml/LogicalView/SensorFusion/HAL_IMU.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
@startuml HAL IMU

title Hardware Abstraction Layer - IMU

package "HAL" as hal {

package "HAL Interfaces" as halInterfaces {
interface "IBoard" as iBoard {
+ {abstract} getIMU() : IIMU&
+ init() : void
}
interface "IIMU" as iIMU {
+ {abstract} init() : bool
+ {abstract} readAcc() : void
+ {abstract} readGyro() : void
+ {abstract} readMag() : void
+ {abstract} accDataReady() : bool
+ {abstract} gyroDataReady() : bool
+ {abstract} magDataReady() : bool
+ {abstract} getAccelerationValues(int16_t* accelerationValues) : void
+ {abstract} getTurnRates(int16_t* turnRates) : void
+ {abstract} getMagnetometerValues(int16_t* magnetometerValues) : void

}
}

package "HAL Simulation" as simulation {
class "IMU" as ImuSim {
- m_accelerationValues[3] : int16_t
- m_gyroValues[3] : int16_t
- m_magnetometerValues[3] : int16_t
+ init() : bool
+ readAcc() : void
+ readGyro() : void
+ readMag() : void
+ accDataReady() : bool
+ gyroDataReady() : bool
+ magDataReady() : bool
+ getAccelerationValues(int16_t* accelerationValues) : void
+ getTurnRates(int16_t* turnRates) : void
+ getMagnetometerValues(int16_t* magnetometerValues) : void
}
class "Board" as BoardSim {
- m_imu : IMU
+ getIMU() : IMU&
+ init() : void
}
}

package "HAL Target" as target {
class "IMU" as ImuTarget {
- m_accelerationValues[3] : vector<int16_t>
- m_gyroValues[3] : vector<int16_t>
- m_magnetometerValues[3] : vector<int16_t>
+ init() : bool
+ readAcc() : void
+ readGyro() : void
+ readMag() : void
+ accDataReady() : bool
+ gyroDataReady() : bool
+ magDataReady() : bool
+ getAccelerationValues(int16_t* accelerationValues) : void
+ getTurnRates(int16_t* turnRates) : void
+ getMagnetometerValues(int16_t* magnetometerValues) : void
}
class "Board" as BoardTarget{
- m_imu : IMU
+ getIMU() : IMU&
+ init() : void
}
}
}
iIMU <|... ImuSim: <<realize>>
iBoard <|... BoardSim: <<realize>>
iBoard *-- iIMU

iIMU <|... ImuTarget: <<realize>>
iBoard <|... BoardTarget: <<realize>>


package "Webots library" as webotsLib {
class Accelerometer {
+ getValues() : double *
+ enable(int samplingPeriod) : void
}
class Gyro {
+ getValues() : double *
+ enable(int samplingPeriod) : void
}
class Compass {
+ getValues() : double *
+ enable(int samplingPeriod) : void
}
}

package "Zumo32U4 library" as zumo32u4Lib {

class Zumo32U4IMU {
- a[3] : vector<int16_t>
- g[3] : vector<int16_t>
- m[3] : vector<int16_t>
+ init() : bool
+ readAcc() : void
+ readGyro() : void
+ readMag() : void
+ accDataReady() : bool
+ gyroDataReady() : bool
+ magDataReady() : bool
}
}

note bottom of zumo32u4Lib
Provided by Pololu.
https://pololu.github.io/zumo-32u4-arduino-library/index.html
end note

note bottom of webotsLib
Provided by Cyberbotics.
https://cyberbotics.com/doc/reference/thanks?version=R2023b
end note

ImuTarget *--> Zumo32U4IMU

ImuSim *--> Accelerometer
ImuSim *--> Gyro
ImuSim *--> Compass

note left of iIMU
IMU stands for Inertial Measurement Unit.
end note

note left of hal
This diagram shows the added IMU component.
Classes like the LineSensors or Motors
are missing.
end note


@enduml
Loading