Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MA-benchmarking
Warehouse PMSV Robot
Commits
5349f359
Commit
5349f359
authored
Jan 04, 2021
by
Niels Post
Browse files
- Added the robot ID as a configuration Parameter
- The robot now listens to its own address pipe - Added reboot command
parent
3bb3c502
Pipeline
#32
failed with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/communication/communicationboundary/NRF24CommunicationBoundary.hpp
View file @
5349f359
...
...
@@ -3,8 +3,7 @@
#include <communication/communicationboundary/NRF24Configuration.hpp>
#include <core/communication/BaseCommunicationBoundary.hpp>
#include <core/PMSVSettings.hpp>
/**
...
...
@@ -17,6 +16,8 @@ class NRF24CommunicationBoundary : public BaseCommunicationBoundary {
/// Configuration of the NRF Boundary
NRFConfiguration
&
config
;
PMSVSettings
&
settings
;
/// The radio used to communicate with the other party
RF24
nrfRadio
;
...
...
@@ -29,7 +30,7 @@ public:
*
* @param _config Configuration to set up
*/
NRF24CommunicationBoundary
(
NRFConfiguration
&
_config
);
NRF24CommunicationBoundary
(
NRFConfiguration
&
_config
,
PMSVSettings
&
settings
);
/**
* Send a message over RF to the controller
...
...
include/core/communication/CommandRegistry.hpp
View file @
5349f359
...
...
@@ -16,7 +16,7 @@ enum class CommandCategory : uint8_t {
* Commands in the "General" category
*/
enum
GeneralCommand
{
SET_COMMUNICATION_ACTIVEMODE
=
0
REBOOT
=
0
};
/**
...
...
include/core/util/ArraySize.hpp
0 → 100644
View file @
5349f359
#include <cstddef>
#pragma once
template
<
typename
T
,
unsigned
int
sz
>
inline
size_t
lengthof
(
T
(
&
)[
sz
])
{
return
sz
;
}
\ No newline at end of file
src/communication/commandcontroller/CommandController_General.cpp
View file @
5349f359
...
...
@@ -3,6 +3,10 @@
Response
CommandController_General
::
handle
(
const
Command
&
cmd
,
ResponseCallback
callback
)
{
switch
(
cmd
.
command_id
)
{
case
REBOOT
:
rstc_start_software_reset
(
RSTC
);
}
return
{
0
,
SuccessCode
::
UNKNOWN_COMMAND
};
}
...
...
@@ -14,8 +18,8 @@ CommandController_General::CommandController_General() {}
std
::
pair
<
uint8_t
,
uint8_t
>
CommandController_General
::
getParameterLimits
(
uint8_t
command_id
)
{
switch
(
command_id
)
{
case
SET_COMMUNICATION_ACTIVEMODE
:
return
{
1
,
1
};
case
REBOOT
:
return
{
0
,
0
};
default:
return
{
255
,
255
};
}
...
...
src/communication/method/NRF24CommunicationBoundary.cpp
View file @
5349f359
#include <communication/communicationboundary/NRF24CommunicationBoundary.hpp>
NRF24CommunicationBoundary
::
NRF24CommunicationBoundary
(
NRFConfiguration
&
_config
)
:
config
(
_config
),
nrfRadio
(
config
.
pin_ce
,
config
.
pin_csn
)
{
NRF24CommunicationBoundary
::
NRF24CommunicationBoundary
(
NRFConfiguration
&
_config
,
PMSVSettings
&
settings
)
:
config
(
_config
),
settings
(
settings
),
nrfRadio
(
config
.
pin_ce
,
config
.
pin_csn
)
{
nrfRadio
.
begin
();
nrfRadio
.
setPALevel
(
config
.
palevel
);
...
...
@@ -18,10 +19,15 @@ NRF24CommunicationBoundary::NRF24CommunicationBoundary(NRFConfiguration &_config
nrfRadio
.
setChannel
(
config
.
channel
);
nrfRadio
.
openReadingPipe
(
1
,
config
.
base_reading_pipe
&
~
0xFFu
);
nrfRadio
.
openWritingPipe
(
config
.
base_writing_pipe
&
~
0xFFu
);
const
uint64_t
base_address_mask
=
0x000000FFu
;
nrfRadio
.
openReadingPipe
(
1
,
config
.
base_reading_pipe
&
~
base_address_mask
);
nrfRadio
.
openReadingPipe
(
2
,
(
config
.
base_reading_pipe
&
~
base_address_mask
)
|
settings
.
robot_id
);
nrfRadio
.
openWritingPipe
((
config
.
base_writing_pipe
&
~
base_address_mask
)
|
settings
.
robot_id
);
nrfRadio
.
powerUp
();
nrfRadio
.
printDetails
();
nrfRadio
.
startListening
();
}
...
...
src/core/configuration/BaseConfigurationValue.cpp
View file @
5349f359
...
...
@@ -37,13 +37,11 @@ void BaseConfigurationValue::print_info() {
}
void
BaseConfigurationValue
::
store
()
{
Serial
.
println
(
"storing"
);
auto
data
=
get
();
storage
.
write
(
ADDRESS_START
,
(
uint8_t
*
)
data
.
first
,
data
.
second
);
}
void
BaseConfigurationValue
::
load
()
{
Serial
.
println
(
"loading"
);
uint8_t
*
flash_data
=
storage
.
readAddress
(
ADDRESS_START
);
set
(
flash_data
);
...
...
src/main.cpp
View file @
5349f359
#include <core/configuration/ConfigurationValue.hpp>
#include <core/PMSVSettings.hpp>
#include <communication/communicationboundary/NRF24Configuration.hpp>
#include <movement/motorboundary/AccelStepperConfig.hpp>
...
...
@@ -15,6 +11,8 @@
#include <communication/commandcontroller/CommandController_Action.hpp>
#include <core/communication/CommunicationController.hpp>
#include <core/util/ArraySize.hpp>
#include <utility>
#define R_SENSE 0.11f
...
...
@@ -22,13 +20,15 @@
//################################################################## Configuration ###################################
PMSVSettings
default_settings
{
0
,
0
xE4
,
1.434684
f
,
1.4545
f
,
0
,
180
};
auto
c_robot_id
=
registerConfig
(
"ROBOT_ID"
,
default_settings
.
robot_id
);
auto
c_rot_per_mm
=
registerConfig
(
"MOTOR_ROTATION_PER_MM_DISTANCE"
,
default_settings
.
motor_rotation_degrees_per_mm_distance
);
auto
c_mm_per_rot
=
registerConfig
(
"MM_DISTANCE_PER_ROBOT_ROTATION"
,
...
...
@@ -94,6 +94,7 @@ auto c_RIGHTmotor_forward_direction = registerConfig("RIGHTMOTOR_FORWARD_DIRECTI
std
::
reference_wrapper
<
BaseConfigurationValue
>
configurationValues
[]{
c_robot_id
,
c_rot_per_mm
,
c_mm_per_rot
,
c_min_speed
,
...
...
@@ -129,9 +130,9 @@ void setup() {
Serial
.
begin
(
9600
);
// Set up Boundaries
CommandController_Configuration
flashCommandController
{
configurationValues
,
23
};
CommandController_Configuration
flashCommandController
{
configurationValues
,
lengthof
(
configurationValues
)
};
NRF24CommunicationBoundary
nrfBoundary
{
nrf_config
};
NRF24CommunicationBoundary
nrfBoundary
{
nrf_config
,
default_settings
};
MotorBoundary_AccelStepper
leftMotor
{
leftMotorConfig
};
...
...
@@ -153,8 +154,7 @@ void setup() {
};
CommunicationController
communicationController
{
nrfBoundary
,
commandControllers
,
4
};
Serial
.
println
(
"Init done"
);
CommunicationController
communicationController
{
nrfBoundary
,
commandControllers
,
lengthof
(
commandControllers
)};
volatile
bool
_true
=
true
;
while
(
_true
)
{
movementController
.
update
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment