diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8d164a5..2524db4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -20,7 +20,7 @@ RUN sudo apt-get update && \ build-essential sudo git cmake gdb clang clang-format cppcheck bash-completion python3-pip curl gcc-arm-none-eabi && \ python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" && \ ln -s /home/husarion/.platformio/penv/bin/platformio /bin/pio && \ - pip install -U colcon-common-extensions + pip install -U colcon-common-extensions lark # Build core2-flasher RUN git clone https://github.com/husarion/flasher && \ @@ -30,4 +30,4 @@ RUN git clone https://github.com/husarion/flasher && \ # Build stm32 flasher RUN git clone https://github.com/husarion/stm32loader && \ - cd stm32loader && sudo python setup.py install \ No newline at end of file + cd stm32loader && sudo python setup.py install \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 613814e..0174091 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -26,5 +26,5 @@ ], "workspaceMount": "src=${localWorkspaceFolder}/,dst=/home/husarion/rosbot_ros2_firmware/,type=bind", "workspaceFolder": "/home/husarion/rosbot_ros2_firmware/", - "remoteUser": "husarion", + "remoteUser": "husarion" } \ No newline at end of file diff --git a/ignore_packages.py b/ignore_packages.py new file mode 100644 index 0000000..bc61114 --- /dev/null +++ b/ignore_packages.py @@ -0,0 +1,4 @@ +with open('/home/husarion/.platformio/packages/framework-mbed/features/.mbedignore', 'w') as f: + f.write('cellular/*\n') + f.write('netsocket/cellular/*\n') + f.write('nanostack/*\n') \ No newline at end of file diff --git a/include/rosbot_ekf/Configuration.h b/include/rosbot_ekf/Configuration.h deleted file mode 100644 index c649d97..0000000 --- a/include/rosbot_ekf/Configuration.h +++ /dev/null @@ -1,142 +0,0 @@ -#pragma once -// #ifndef _ROS_SERVICE_Configuration_h -// #define _ROS_SERVICE_Configuration_h -// #include -// #include -// #include -// // #include "ros/msg.h" - -namespace rosbot_ekf -{ - -// static const char CONFIGURATION[] = "rosbot_ekf/Configuration"; - -// class ConfigurationRequest : public ros::Msg -// { -// public: -// typedef const char* _command_type; -// _command_type command; -// typedef const char* _data_type; -// _data_type data; - -// ConfigurationRequest(): -// command(""), -// data("") -// { -// } - -// virtual int serialize(unsigned char *outbuffer) const -// { -// int offset = 0; -// uint32_t length_command = strlen(this->command); -// varToArr(outbuffer + offset, length_command); -// offset += 4; -// memcpy(outbuffer + offset, this->command, length_command); -// offset += length_command; -// uint32_t length_data = strlen(this->data); -// varToArr(outbuffer + offset, length_data); -// offset += 4; -// memcpy(outbuffer + offset, this->data, length_data); -// offset += length_data; -// return offset; -// } - -// virtual int deserialize(unsigned char *inbuffer) -// { -// int offset = 0; -// uint32_t length_command; -// arrToVar(length_command, (inbuffer + offset)); -// offset += 4; -// for(unsigned int k= offset; k< offset+length_command; ++k){ -// inbuffer[k-1]=inbuffer[k]; -// } -// inbuffer[offset+length_command-1]=0; -// this->command = (char *)(inbuffer + offset-1); -// offset += length_command; -// uint32_t length_data; -// arrToVar(length_data, (inbuffer + offset)); -// offset += 4; -// for(unsigned int k= offset; k< offset+length_data; ++k){ -// inbuffer[k-1]=inbuffer[k]; -// } -// inbuffer[offset+length_data-1]=0; -// this->data = (char *)(inbuffer + offset-1); -// offset += length_data; -// return offset; -// } - -// const char * getType(){ return CONFIGURATION; }; -// const char * getMD5(){ return "b116973260063b7b02b501a288810d3d"; }; - -// }; - -// class ConfigurationResponse : public ros::Msg -// { -// public: -// typedef const char* _data_type; -// _data_type data; -// typedef uint8_t _result_type; -// _result_type result; -// enum { SUCCESS = 0 }; -// enum { FAILURE = 1 }; -// enum { COMMAND_NOT_FOUND = 2 }; - -// ConfigurationResponse(): -// data(""), -// result(0) -// { -// } - -// virtual int serialize(unsigned char *outbuffer) const -// { -// int offset = 0; -// uint32_t length_data = strlen(this->data); -// varToArr(outbuffer + offset, length_data); -// offset += 4; -// memcpy(outbuffer + offset, this->data, length_data); -// offset += length_data; -// *(outbuffer + offset + 0) = (this->result >> (8 * 0)) & 0xFF; -// offset += sizeof(this->result); -// return offset; -// } - -// virtual int deserialize(unsigned char *inbuffer) -// { -// int offset = 0; -// uint32_t length_data; -// arrToVar(length_data, (inbuffer + offset)); -// offset += 4; -// for(unsigned int k= offset; k< offset+length_data; ++k){ -// inbuffer[k-1]=inbuffer[k]; -// } -// inbuffer[offset+length_data-1]=0; -// this->data = (char *)(inbuffer + offset-1); -// offset += length_data; -// this->result = ((uint8_t) (*(inbuffer + offset))); -// offset += sizeof(this->result); -// return offset; -// } - -// const char * getType(){ return CONFIGURATION; }; -// const char * getMD5(){ return "d26ad64e1f52355ee24245b602a171ba"; }; - -// }; - - -class ConfigurationRequest { -}; - -class ConfigurationResponse { - public: - enum { SUCCESS = 0 }; - enum { FAILURE = 1 }; - enum { COMMAND_NOT_FOUND = 2 }; -}; - -class Configuration { - public: - typedef ConfigurationRequest Request; - typedef ConfigurationResponse Response; -}; -} -// #endif diff --git a/include/rosbot_ekf/Imu.h b/include/rosbot_ekf/Imu.h deleted file mode 100644 index 83ebe9b..0000000 --- a/include/rosbot_ekf/Imu.h +++ /dev/null @@ -1,104 +0,0 @@ -// #ifndef _ROS_rosbot_ekf_Imu_h -// #define _ROS_rosbot_ekf_Imu_h - -// #include -// #include -// #include -// #include "ros/msg.h" -// #include "std_msgs/Header.h" -// #include "geometry_msgs/Quaternion.h" - -// namespace rosbot_ekf -// { - -// class Imu : public ros::Msg -// { -// public: -// typedef std_msgs::Header _header_type; -// _header_type header; -// typedef geometry_msgs::Quaternion _orientation_type; -// _orientation_type orientation; -// float angular_velocity[3]; -// float linear_acceleration[3]; - -// Imu(): -// header(), -// orientation(), -// angular_velocity(), -// linear_acceleration() -// { -// } - -// virtual int serialize(unsigned char *outbuffer) const -// { -// int offset = 0; -// offset += this->header.serialize(outbuffer + offset); -// offset += this->orientation.serialize(outbuffer + offset); -// for( uint32_t i = 0; i < 3; i++){ -// union { -// float real; -// uint32_t base; -// } u_angular_velocityi; -// u_angular_velocityi.real = this->angular_velocity[i]; -// *(outbuffer + offset + 0) = (u_angular_velocityi.base >> (8 * 0)) & 0xFF; -// *(outbuffer + offset + 1) = (u_angular_velocityi.base >> (8 * 1)) & 0xFF; -// *(outbuffer + offset + 2) = (u_angular_velocityi.base >> (8 * 2)) & 0xFF; -// *(outbuffer + offset + 3) = (u_angular_velocityi.base >> (8 * 3)) & 0xFF; -// offset += sizeof(this->angular_velocity[i]); -// } -// for( uint32_t i = 0; i < 3; i++){ -// union { -// float real; -// uint32_t base; -// } u_linear_accelerationi; -// u_linear_accelerationi.real = this->linear_acceleration[i]; -// *(outbuffer + offset + 0) = (u_linear_accelerationi.base >> (8 * 0)) & 0xFF; -// *(outbuffer + offset + 1) = (u_linear_accelerationi.base >> (8 * 1)) & 0xFF; -// *(outbuffer + offset + 2) = (u_linear_accelerationi.base >> (8 * 2)) & 0xFF; -// *(outbuffer + offset + 3) = (u_linear_accelerationi.base >> (8 * 3)) & 0xFF; -// offset += sizeof(this->linear_acceleration[i]); -// } -// return offset; -// } - -// virtual int deserialize(unsigned char *inbuffer) -// { -// int offset = 0; -// offset += this->header.deserialize(inbuffer + offset); -// offset += this->orientation.deserialize(inbuffer + offset); -// for( uint32_t i = 0; i < 3; i++){ -// union { -// float real; -// uint32_t base; -// } u_angular_velocityi; -// u_angular_velocityi.base = 0; -// u_angular_velocityi.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); -// u_angular_velocityi.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); -// u_angular_velocityi.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); -// u_angular_velocityi.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); -// this->angular_velocity[i] = u_angular_velocityi.real; -// offset += sizeof(this->angular_velocity[i]); -// } -// for( uint32_t i = 0; i < 3; i++){ -// union { -// float real; -// uint32_t base; -// } u_linear_accelerationi; -// u_linear_accelerationi.base = 0; -// u_linear_accelerationi.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); -// u_linear_accelerationi.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); -// u_linear_accelerationi.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); -// u_linear_accelerationi.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); -// this->linear_acceleration[i] = u_linear_accelerationi.real; -// offset += sizeof(this->linear_acceleration[i]); -// } -// return offset; -// } - -// const char * getType(){ return "rosbot_ekf/Imu"; }; -// const char * getMD5(){ return "3d83bdcabfe2927ed38c36f102a9f646"; }; - -// }; - -// } -// #endif diff --git a/include/sensor_msgs_noetic/BatteryState.h b/include/sensor_msgs_noetic/BatteryState.h deleted file mode 100644 index c34a652..0000000 --- a/include/sensor_msgs_noetic/BatteryState.h +++ /dev/null @@ -1,394 +0,0 @@ -#ifndef _ROS_sensor_msgs_BatteryState_h -#define _ROS_sensor_msgs_BatteryState_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" - -namespace sensor_msgs -{ - - class BatteryState : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef float _voltage_type; - _voltage_type voltage; - typedef float _temperature_type; - _temperature_type temperature; - typedef float _current_type; - _current_type current; - typedef float _charge_type; - _charge_type charge; - typedef float _capacity_type; - _capacity_type capacity; - typedef float _design_capacity_type; - _design_capacity_type design_capacity; - typedef float _percentage_type; - _percentage_type percentage; - typedef uint8_t _power_supply_status_type; - _power_supply_status_type power_supply_status; - typedef uint8_t _power_supply_health_type; - _power_supply_health_type power_supply_health; - typedef uint8_t _power_supply_technology_type; - _power_supply_technology_type power_supply_technology; - typedef bool _present_type; - _present_type present; - uint32_t cell_voltage_length; - typedef float _cell_voltage_type; - _cell_voltage_type st_cell_voltage; - _cell_voltage_type * cell_voltage; - uint32_t cell_temperature_length; - typedef float _cell_temperature_type; - _cell_temperature_type st_cell_temperature; - _cell_temperature_type * cell_temperature; - typedef const char* _location_type; - _location_type location; - typedef const char* _serial_number_type; - _serial_number_type serial_number; - enum { POWER_SUPPLY_STATUS_UNKNOWN = 0 }; - enum { POWER_SUPPLY_STATUS_CHARGING = 1 }; - enum { POWER_SUPPLY_STATUS_DISCHARGING = 2 }; - enum { POWER_SUPPLY_STATUS_NOT_CHARGING = 3 }; - enum { POWER_SUPPLY_STATUS_FULL = 4 }; - enum { POWER_SUPPLY_HEALTH_UNKNOWN = 0 }; - enum { POWER_SUPPLY_HEALTH_GOOD = 1 }; - enum { POWER_SUPPLY_HEALTH_OVERHEAT = 2 }; - enum { POWER_SUPPLY_HEALTH_DEAD = 3 }; - enum { POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4 }; - enum { POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5 }; - enum { POWER_SUPPLY_HEALTH_COLD = 6 }; - enum { POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7 }; - enum { POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8 }; - enum { POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0 }; - enum { POWER_SUPPLY_TECHNOLOGY_NIMH = 1 }; - enum { POWER_SUPPLY_TECHNOLOGY_LION = 2 }; - enum { POWER_SUPPLY_TECHNOLOGY_LIPO = 3 }; - enum { POWER_SUPPLY_TECHNOLOGY_LIFE = 4 }; - enum { POWER_SUPPLY_TECHNOLOGY_NICD = 5 }; - enum { POWER_SUPPLY_TECHNOLOGY_LIMN = 6 }; - - BatteryState(): - header(), - voltage(0), - temperature(0), - current(0), - charge(0), - capacity(0), - design_capacity(0), - percentage(0), - power_supply_status(0), - power_supply_health(0), - power_supply_technology(0), - present(0), - cell_voltage_length(0), st_cell_voltage(), cell_voltage(nullptr), - cell_temperature_length(0), st_cell_temperature(), cell_temperature(nullptr), - location(""), - serial_number("") - { - } - - virtual int serialize(unsigned char *outbuffer) const override - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - union { - float real; - uint32_t base; - } u_voltage; - u_voltage.real = this->voltage; - *(outbuffer + offset + 0) = (u_voltage.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_voltage.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_voltage.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_voltage.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->voltage); - union { - float real; - uint32_t base; - } u_temperature; - u_temperature.real = this->temperature; - *(outbuffer + offset + 0) = (u_temperature.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_temperature.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_temperature.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_temperature.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->temperature); - union { - float real; - uint32_t base; - } u_current; - u_current.real = this->current; - *(outbuffer + offset + 0) = (u_current.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_current.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_current.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_current.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->current); - union { - float real; - uint32_t base; - } u_charge; - u_charge.real = this->charge; - *(outbuffer + offset + 0) = (u_charge.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_charge.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_charge.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_charge.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->charge); - union { - float real; - uint32_t base; - } u_capacity; - u_capacity.real = this->capacity; - *(outbuffer + offset + 0) = (u_capacity.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_capacity.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_capacity.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_capacity.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->capacity); - union { - float real; - uint32_t base; - } u_design_capacity; - u_design_capacity.real = this->design_capacity; - *(outbuffer + offset + 0) = (u_design_capacity.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_design_capacity.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_design_capacity.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_design_capacity.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->design_capacity); - union { - float real; - uint32_t base; - } u_percentage; - u_percentage.real = this->percentage; - *(outbuffer + offset + 0) = (u_percentage.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_percentage.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_percentage.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_percentage.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->percentage); - *(outbuffer + offset + 0) = (this->power_supply_status >> (8 * 0)) & 0xFF; - offset += sizeof(this->power_supply_status); - *(outbuffer + offset + 0) = (this->power_supply_health >> (8 * 0)) & 0xFF; - offset += sizeof(this->power_supply_health); - *(outbuffer + offset + 0) = (this->power_supply_technology >> (8 * 0)) & 0xFF; - offset += sizeof(this->power_supply_technology); - union { - bool real; - uint8_t base; - } u_present; - u_present.real = this->present; - *(outbuffer + offset + 0) = (u_present.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->present); - *(outbuffer + offset + 0) = (this->cell_voltage_length >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->cell_voltage_length >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->cell_voltage_length >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->cell_voltage_length >> (8 * 3)) & 0xFF; - offset += sizeof(this->cell_voltage_length); - for( uint32_t i = 0; i < cell_voltage_length; i++){ - union { - float real; - uint32_t base; - } u_cell_voltagei; - u_cell_voltagei.real = this->cell_voltage[i]; - *(outbuffer + offset + 0) = (u_cell_voltagei.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_cell_voltagei.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_cell_voltagei.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_cell_voltagei.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->cell_voltage[i]); - } - *(outbuffer + offset + 0) = (this->cell_temperature_length >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->cell_temperature_length >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->cell_temperature_length >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->cell_temperature_length >> (8 * 3)) & 0xFF; - offset += sizeof(this->cell_temperature_length); - for( uint32_t i = 0; i < cell_temperature_length; i++){ - union { - float real; - uint32_t base; - } u_cell_temperaturei; - u_cell_temperaturei.real = this->cell_temperature[i]; - *(outbuffer + offset + 0) = (u_cell_temperaturei.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_cell_temperaturei.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_cell_temperaturei.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_cell_temperaturei.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->cell_temperature[i]); - } - uint32_t length_location = strlen(this->location); - varToArr(outbuffer + offset, length_location); - offset += 4; - memcpy(outbuffer + offset, this->location, length_location); - offset += length_location; - uint32_t length_serial_number = strlen(this->serial_number); - varToArr(outbuffer + offset, length_serial_number); - offset += 4; - memcpy(outbuffer + offset, this->serial_number, length_serial_number); - offset += length_serial_number; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) override - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - union { - float real; - uint32_t base; - } u_voltage; - u_voltage.base = 0; - u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->voltage = u_voltage.real; - offset += sizeof(this->voltage); - union { - float real; - uint32_t base; - } u_temperature; - u_temperature.base = 0; - u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->temperature = u_temperature.real; - offset += sizeof(this->temperature); - union { - float real; - uint32_t base; - } u_current; - u_current.base = 0; - u_current.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_current.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_current.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_current.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->current = u_current.real; - offset += sizeof(this->current); - union { - float real; - uint32_t base; - } u_charge; - u_charge.base = 0; - u_charge.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_charge.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_charge.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_charge.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->charge = u_charge.real; - offset += sizeof(this->charge); - union { - float real; - uint32_t base; - } u_capacity; - u_capacity.base = 0; - u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->capacity = u_capacity.real; - offset += sizeof(this->capacity); - union { - float real; - uint32_t base; - } u_design_capacity; - u_design_capacity.base = 0; - u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->design_capacity = u_design_capacity.real; - offset += sizeof(this->design_capacity); - union { - float real; - uint32_t base; - } u_percentage; - u_percentage.base = 0; - u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_percentage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->percentage = u_percentage.real; - offset += sizeof(this->percentage); - this->power_supply_status = ((uint8_t) (*(inbuffer + offset))); - offset += sizeof(this->power_supply_status); - this->power_supply_health = ((uint8_t) (*(inbuffer + offset))); - offset += sizeof(this->power_supply_health); - this->power_supply_technology = ((uint8_t) (*(inbuffer + offset))); - offset += sizeof(this->power_supply_technology); - union { - bool real; - uint8_t base; - } u_present; - u_present.base = 0; - u_present.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->present = u_present.real; - offset += sizeof(this->present); - uint32_t cell_voltage_lengthT = ((uint32_t) (*(inbuffer + offset))); - cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - cell_voltage_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->cell_voltage_length); - if(cell_voltage_lengthT > cell_voltage_length) - this->cell_voltage = (float*)realloc(this->cell_voltage, cell_voltage_lengthT * sizeof(float)); - cell_voltage_length = cell_voltage_lengthT; - for( uint32_t i = 0; i < cell_voltage_length; i++){ - union { - float real; - uint32_t base; - } u_st_cell_voltage; - u_st_cell_voltage.base = 0; - u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_st_cell_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->st_cell_voltage = u_st_cell_voltage.real; - offset += sizeof(this->st_cell_voltage); - memcpy( &(this->cell_voltage[i]), &(this->st_cell_voltage), sizeof(float)); - } - uint32_t cell_temperature_lengthT = ((uint32_t) (*(inbuffer + offset))); - cell_temperature_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - cell_temperature_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - cell_temperature_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->cell_temperature_length); - if(cell_temperature_lengthT > cell_temperature_length) - this->cell_temperature = (float*)realloc(this->cell_temperature, cell_temperature_lengthT * sizeof(float)); - cell_temperature_length = cell_temperature_lengthT; - for( uint32_t i = 0; i < cell_temperature_length; i++){ - union { - float real; - uint32_t base; - } u_st_cell_temperature; - u_st_cell_temperature.base = 0; - u_st_cell_temperature.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_st_cell_temperature.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_st_cell_temperature.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_st_cell_temperature.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->st_cell_temperature = u_st_cell_temperature.real; - offset += sizeof(this->st_cell_temperature); - memcpy( &(this->cell_temperature[i]), &(this->st_cell_temperature), sizeof(float)); - } - uint32_t length_location; - arrToVar(length_location, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_location; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_location-1]=0; - this->location = (char *)(inbuffer + offset-1); - offset += length_location; - uint32_t length_serial_number; - arrToVar(length_serial_number, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_serial_number; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_serial_number-1]=0; - this->serial_number = (char *)(inbuffer + offset-1); - offset += length_serial_number; - return offset; - } - - virtual const char * getType() override { return "sensor_msgs/BatteryState"; }; - virtual const char * getMD5() override { return "4ddae7f048e32fda22cac764685e3974"; }; - - }; - -} -#endif diff --git a/mbed_app.json b/mbed_app.json index 9c3063d..6fa10e2 100644 --- a/mbed_app.json +++ b/mbed_app.json @@ -1,8 +1,4 @@ { - "macros": [ - "ROSBOT_FW_VERSION=\"0.15.0\"", - "WELLCOME_BANNER" - ], "target_overrides": { "CORE2": { "platform.all-stats-enabled": false, diff --git a/platformio.ini b/platformio.ini index 1d7648a..0f1d838 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,7 @@ platform_packages = extra_scripts = post:gen_hex.py + pre:ignore_packages.py board_microros_distro = humble board_microros_transport = custom