-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from aabadie/swarmit_demo
swarmit: add sample application compatible with swarmit
- Loading branch information
Showing
18 changed files
with
469 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ applications | |
examples | ||
otap | ||
upgate | ||
swarmit | ||
api | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```{include} ../../swarmit/README.md | ||
:relative-images: | ||
:relative-docs: ../ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SwarmIT samples | ||
|
||
[SwarmIT](https://github.com/dotbots/swarmit) provides a lightweight | ||
infrastructure to turn a swarm of robots in a testbed. | ||
|
||
3 sample applications, compatible with SwarmIT, are provided to show how to | ||
adapt DotBot-firmware code. | ||
The sample applications are only compatible with the DotBot-v2 target, the only | ||
robot powered by an nRF53 microcontroller, which is a requirement of SwarmIT. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Motors board support package usage example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @file | ||
* @defgroup swarmit_motors Motors application on top of SwarmIT | ||
* @ingroup swarmit | ||
* @brief This application controls the motors of the robot | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* @copyright Inria, 2024 | ||
*/ | ||
|
||
#include <nrf.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "board.h" | ||
#include "motors.h" | ||
#include "timer.h" | ||
|
||
//=========================== swarmit ========================================== | ||
|
||
void reload_wdt0(void); | ||
|
||
//=========================== defines ========================================== | ||
|
||
#define TIMER_DEV (0) | ||
|
||
//=========================== main ============================================= | ||
|
||
int main(void) { | ||
|
||
// Turn ON the DotBot board regulator | ||
db_board_init(); | ||
|
||
// Initialize the timer | ||
db_timer_init(TIMER_DEV); | ||
|
||
db_timer_init(1); | ||
db_timer_set_periodic_ms(1, 0, 500, &reload_wdt0); | ||
|
||
// Configure Motors | ||
db_motors_init(); | ||
|
||
while (1) { | ||
// Move forward | ||
for (uint8_t speed = 50; speed < 80; speed++) { | ||
db_motors_set_speed(speed, speed); | ||
db_timer_delay_ms(TIMER_DEV, 30); | ||
} | ||
|
||
// Move backward | ||
for (uint8_t speed = 50; speed < 80; speed++) { | ||
db_motors_set_speed(speed * -1, speed * -1); | ||
db_timer_delay_ms(TIMER_DEV, 30); | ||
} | ||
|
||
// Spin | ||
db_motors_set_speed(-70, 70); | ||
db_timer_delay_ms(TIMER_DEV, 500); | ||
|
||
// Spin back | ||
db_motors_set_speed(70, -70); | ||
db_timer_delay_ms(TIMER_DEV, 500); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# High-level move controls for the DotBot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @file | ||
* @defgroup swarmit_move Move application on top of SwarmIT | ||
* @ingroup swarmit | ||
* @brief This application uses the move API to make the robot move | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* @copyright Inria, 2024 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <nrf.h> | ||
#include "move.h" | ||
#include "timer.h" | ||
#include "gpio.h" | ||
#include "board_config.h" | ||
|
||
//=========================== swarmit ========================================== | ||
|
||
void reload_wdt0(void); | ||
|
||
//=========================== main ============================================= | ||
|
||
int main(void) { | ||
db_timer_init(1); | ||
db_timer_set_periodic_ms(1, 0, 500, &reload_wdt0); | ||
|
||
db_gpio_init(&db_led1, DB_GPIO_OUT); | ||
|
||
db_move_init(); | ||
db_move_straight(200, 60); | ||
db_move_rotate(90, 60); | ||
db_move_straight(200, 60); | ||
db_move_rotate(90, 60); | ||
db_move_straight(200, 60); | ||
db_move_rotate(90, 60); | ||
db_move_straight(200, 60); | ||
db_move_rotate(90, 60); | ||
|
||
while (1) { | ||
db_gpio_toggle(&db_led1); | ||
db_timer_delay_ms(1, 250); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE Board_Memory_Definition_File> | ||
<root name="nRF5340_xxAA_Application"> | ||
<MemorySegment name="FLASH1" start="0x00004000" size="0x00100000 - 0x4000" access="ReadOnly" /> | ||
<MemorySegment name="NSC_FLASH" start="0x00004000 - 0x100" size="0x00000100" access="ReadOnly" /> | ||
<MemorySegment name="EXT_FLASH1" start="0x10000000" size="0x08000000" access="ReadOnly" /> | ||
<MemorySegment name="RAM1" start="0x20020000" size="0x00020000" access="Read/Write" /> | ||
<MemorySegment name="RAM2" start="0x20040000" size="0x0003F000" access="Read/Write" /> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE Linker_Placement_File> | ||
<Root name="Flash Section Placement"> | ||
<MemorySegment name="$(FLASH_NAME:FLASH);FLASH1"> | ||
<ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" /> | ||
<ProgramSection alignment="4" load="Yes" name=".init" /> | ||
<ProgramSection alignment="4" load="Yes" name=".init_rodata" /> | ||
<ProgramSection alignment="4" load="Yes" name=".text" /> | ||
<ProgramSection alignment="4" load="Yes" name=".dtors" /> | ||
<ProgramSection alignment="4" load="Yes" name=".ctors" /> | ||
<ProgramSection alignment="4" load="Yes" name=".rodata" /> | ||
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" /> | ||
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" /> | ||
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" /> | ||
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" /> | ||
</MemorySegment> | ||
<MemorySegment name="$(RAM_NAME:RAM);SRAM;RAM1"> | ||
<ProgramSection alignment="4" load="No" name=".fast_run" /> | ||
<ProgramSection alignment="4" load="No" name=".data_run" /> | ||
<ProgramSection alignment="4" load="No" name=".bss" /> | ||
<ProgramSection alignment="4" load="No" name=".tbss" /> | ||
<ProgramSection alignment="4" load="No" name=".tdata_run" /> | ||
<ProgramSection alignment="4" load="No" name=".non_init" /> | ||
<ProgramSection alignment="8" size="__HEAPSIZE__" load="No" name=".heap" /> | ||
<ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" /> | ||
<ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" /> | ||
</MemorySegment> | ||
<MemorySegment name="$(FLASH2_NAME:FLASH2)"> | ||
<ProgramSection alignment="4" load="Yes" name=".text2" /> | ||
<ProgramSection alignment="4" load="Yes" name=".rodata2" /> | ||
<ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" /> | ||
</MemorySegment> | ||
<MemorySegment name="$(RAM2_NAME:RAM2)"> | ||
<ProgramSection alignment="4" load="No" name=".data2_run" /> | ||
<ProgramSection alignment="4" load="No" name=".bss2" /> | ||
</MemorySegment> | ||
</Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* @defgroup swarmit SwarmIT sample applications | ||
* @brief Sample applications showcasing SwarmIT usage with DotBot-firmware | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# RGB LED sample | ||
|
||
Loading this app onto the DotBot board will change the RGB LED color every 2 | ||
seconds in a loop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @file | ||
* @defgroup swarmit_rgbled RGBLed application on top of SwarmIT | ||
* @ingroup swarmit | ||
* @brief This application uses the RGB LED API | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* @copyright Inria, 2024 | ||
*/ | ||
|
||
#include <nrf.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "board.h" | ||
#include "rgbled_pwm.h" | ||
#include "timer.h" | ||
#include "board_config.h" | ||
|
||
//=========================== swarmit ========================================== | ||
|
||
void reload_wdt0(void); | ||
|
||
//=========================== defines ========================================== | ||
|
||
#define TIMER_DEV (0) | ||
#define RGB_LED_DELAY_MS (200U) | ||
|
||
//=========================== variables ======================================== | ||
|
||
static const db_rgbled_pwm_conf_t rgbled_pwm_conf = { | ||
.pwm = 1, | ||
.pins = { | ||
{ .port = DB_RGB_LED_PWM_RED_PORT, .pin = DB_RGB_LED_PWM_RED_PIN }, | ||
{ .port = DB_RGB_LED_PWM_GREEN_PORT, .pin = DB_RGB_LED_PWM_GREEN_PIN }, | ||
{ .port = DB_RGB_LED_PWM_BLUE_PORT, .pin = DB_RGB_LED_PWM_BLUE_PIN }, | ||
} | ||
}; | ||
|
||
//=========================== main ============================================= | ||
|
||
int main(void) { | ||
db_board_init(); | ||
|
||
db_timer_init(TIMER_DEV); | ||
db_timer_set_periodic_ms(TIMER_DEV, 0, 500, &reload_wdt0); | ||
|
||
db_rgbled_pwm_init(&rgbled_pwm_conf); | ||
|
||
/* Change RGB colors in a loop */ | ||
while (1) { | ||
db_rgbled_pwm_set_color(255, 0, 0); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
db_rgbled_pwm_set_color(0, 255, 0); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
db_rgbled_pwm_set_color(0, 0, 255); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
db_rgbled_pwm_set_color(255, 255, 0); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
db_rgbled_pwm_set_color(0, 255, 255); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
db_rgbled_pwm_set_color(255, 0, 255); | ||
db_timer_delay_ms(TIMER_DEV, RGB_LED_DELAY_MS); | ||
} | ||
} |
Oops, something went wrong.