-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved all functionalities to modules --------- Signed-off-by: Jakub Delicat <jakub.delicat@husarion.com>
- Loading branch information
Showing
24 changed files
with
915 additions
and
774 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
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,36 @@ | ||
#pragma once | ||
|
||
#include <mbed.h> | ||
|
||
#include <sensor_msgs/msg/battery_state.h> | ||
#include <rmw_microros/rmw_microros.h> | ||
#include <micro_ros_utilities/string_utilities.h> | ||
|
||
constexpr int MEASUREMENT_SERIES = 10; | ||
constexpr float BATTERY_VOLTAGE_LOW = 10.8; | ||
|
||
enum | ||
{ | ||
BATTERY_LOW = 1, | ||
BATTERY_OK = 0 | ||
}; | ||
|
||
struct BatteryData | ||
{ | ||
float voltage; | ||
float threshold; | ||
uint8_t status; | ||
}; | ||
|
||
static BatteryData battery_data = { 0.0, BATTERY_VOLTAGE_LOW, BATTERY_OK }; | ||
static DigitalOut battery_led(LED1, 1); | ||
static Ticker battery_led_flipper; | ||
static AnalogIn battery_adc(BAT_MEAS); | ||
|
||
extern sensor_msgs__msg__BatteryState battery_msg; | ||
static rtos::Thread read_battery_voltage_and_show_status_thead; | ||
|
||
void init_battery(); | ||
float read_battery_voltage_and_show_status(); | ||
void read_battery_voltage_and_show_status_task(); | ||
void fill_battery_msg(sensor_msgs__msg__BatteryState *msg); |
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,16 @@ | ||
#pragma once | ||
|
||
#include <mbed.h> | ||
|
||
#include <std_msgs/msg/bool.h> | ||
|
||
enum Buttons | ||
{ | ||
button_left, | ||
button_right, | ||
BUTTONS_COUNT | ||
}; | ||
|
||
static volatile bool buttons_publish_flag[BUTTONS_COUNT] = { false, false }; | ||
static std_msgs__msg__Bool button_msgs[BUTTONS_COUNT]; | ||
void init_button_and_attach_to_callbacks(mbed::InterruptIn *interrupt, void (*rise)(), void (*fall)()); |
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,21 @@ | ||
#pragma once | ||
|
||
#include <mbed.h> | ||
#include <ImuDriver.h> | ||
|
||
#include <rmw_microros/rmw_microros.h> | ||
#include <micro_ros_utilities/string_utilities.h> | ||
#include <sensor_msgs/msg/imu.h> | ||
|
||
|
||
static ImuDriver *imu_driver_ptr; | ||
static sensor_msgs__msg__Imu imu_msg; | ||
extern Mail<ImuDriver::ImuMeasurement, 10> imu_sensor_mail_box; | ||
|
||
|
||
static const char* imu_sensor_type_string[] = { "BNO055_ADDR_A", "BNO055_ADDR_B", "MPU9250", "MPU9255", "BHI260", "UNKNOWN" }; | ||
static char imu_description_string[64] = ""; | ||
|
||
void init_imu(mbed::I2C *i2c_ptr); | ||
void fill_imu_msg(sensor_msgs__msg__Imu *msg); | ||
void fill_imu_msg_with_measurements(sensor_msgs__msg__Imu* msg, ImuDriver::ImuMeasurement* measurements); |
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,16 @@ | ||
#pragma once | ||
#include <mbed.h> | ||
#include <std_msgs/msg/bool.h> | ||
|
||
enum LEDs | ||
{ | ||
led_left, | ||
led_right, | ||
LED_COUNT | ||
}; | ||
|
||
static DigitalOut led2(LED2, 0); | ||
static DigitalOut led3(LED3, 0); | ||
|
||
void led1_callback(const void* message); | ||
void led2_callback(const void* message); |
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 |
---|---|---|
@@ -1,70 +1,7 @@ | ||
#pragma once | ||
#include <ImuDriver.h> | ||
#include <RosbotDrive.h> | ||
|
||
#include <memory_debug_message_info.hpp> | ||
#include <microros.hpp> | ||
#include <map> | ||
|
||
#ifndef KINEMATIC_TYPE | ||
#define KINEMATIC_TYPE 0 | ||
#endif | ||
|
||
#ifndef JOINT_STATES_ENABLE | ||
#define JOINT_STATES_ENABLE 0 | ||
#endif | ||
|
||
#if JOINT_STATES_ENABLE | ||
static volatile bool joint_states_enabled = true; | ||
#else | ||
static volatile bool joint_states_enabled = false; | ||
#endif | ||
static UARTSerial microros_serial(RPI_SERIAL_TX, RPI_SERIAL_RX); | ||
|
||
static volatile bool distance_sensors_enabled = false; | ||
|
||
static volatile bool buttons_publish_flag[BUTTONS_COUNT] = {false, false}; | ||
static volatile float button_release_time = 0.1; | ||
|
||
static volatile float battery_voltage = 0.0; | ||
|
||
static volatile bool is_speed_watchdog_enabled = true; | ||
static volatile bool is_speed_watchdog_active = false; | ||
static uint64_t speed_watchdog_interval = 1000; // ms | ||
|
||
static Timer odom_watchdog_timer; | ||
static volatile uint32_t last_speed_command_time = 0; | ||
|
||
static DigitalOut sens_power(SENS_POWER_ON, 0); | ||
|
||
static InterruptIn button1(BUTTON1); | ||
static InterruptIn button2(BUTTON2); | ||
static ImuDriver *imu_driver_ptr; | ||
static rosbot_sensors::ServoManger servo_manager; | ||
|
||
std::map<double, uint8_t> servo_voltage_configuration{ | ||
{5.0, 0}, | ||
{6.0, 1}, | ||
{7.4, 2}, | ||
{8.6, 3} | ||
}; | ||
|
||
// Motors setup | ||
#define MOTOR_FR MOTOR1 | ||
#define MOTOR_FL MOTOR4 | ||
#define MOTOR_RR MOTOR2 | ||
#define MOTOR_RL MOTOR3 | ||
|
||
constexpr uint8_t POLARITY = 0b00111100; | ||
constexpr float ROBOT_LENGTH = 0.197; | ||
constexpr uint8_t ENCODER_CPR = 48; | ||
constexpr float ROBOT_LENGTH_HALF = ROBOT_LENGTH / 2.0; | ||
constexpr float DISTANCE_FRONT_TO_REAR_WHEEL = 0.11; | ||
constexpr float WHEEL_SEPARATION_LENGTH = DISTANCE_FRONT_TO_REAR_WHEEL / 2; | ||
constexpr float ROBOT_WIDTH = 0.215; // 0.22 0.195 | ||
constexpr float ROBOT_WIDTH_HALF = ROBOT_WIDTH / 2.0; | ||
constexpr float DIAMETER_MODIFICATOR = 1.106; // 1.24, 1.09, 1.164 | ||
constexpr float TYRE_DEFLATION = 1.042; // theoretical distance / real distance | ||
constexpr float GEAR_RATIO = 34.014; | ||
constexpr float WHEEL_DIAMETER = 0.085; | ||
constexpr float WHEEL_RADIUS = WHEEL_DIAMETER / 2.0; |
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,24 @@ | ||
#pragma once | ||
|
||
#include <mbed.h> | ||
#include <MultiDistanceSensor.h> | ||
|
||
#include <rmw_microros/rmw_microros.h> | ||
#include <micro_ros_utilities/string_utilities.h> | ||
#include <sensor_msgs/msg/range.h> | ||
|
||
enum Ranges { | ||
range_right_front, | ||
range_left_front, | ||
range_right_rear, | ||
range_left_rear, | ||
RANGES_COUNT | ||
}; | ||
|
||
static const char *range_frame_names[] = {"fr_range", "fl_range", "rr_range", "rl_range"}; | ||
|
||
static sensor_msgs__msg__Range range_msgs[RANGES_COUNT]; | ||
|
||
void init_ranges(); | ||
void fill_range_msg(sensor_msgs__msg__Range *msg, uint8_t id); | ||
void fill_range_msg_with_measurements(sensor_msgs__msg__Range *msg, float range); |
Oops, something went wrong.