Dependencies: SimpleMapSerialization serial_communication
Diff: communication.cpp
- Revision:
- 0:8b0edcbd3b87
- Child:
- 2:074942a78af1
diff -r 000000000000 -r 8b0edcbd3b87 communication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/communication.cpp Thu Mar 31 04:43:01 2016 +0000 @@ -0,0 +1,70 @@ +#include "communication.hpp" +#include "moving_object.hpp" +#include "serial_communication.hpp" + +#include "mbed_stl.hpp" + + +#include "mbed.h" + +communication* communication::instance_ = NULL; + +node_system::moving_object::CONTROL_MODE communication::get_mode() const { + return node_system::moving_object::MANUAL_MODE; +} + +communication::vector2f communication::get_velocity() const { + uint32_t iv[] = { + serial_communication::instance()->get_data("stkLX"), + serial_communication::instance()->get_data("stkLY") + }; + + // 受信データは [0, 65535] の範囲であるので [-1, 1] に変換する + int offset = 32767; + + if ((iv[0] == offset) && (iv[1] == offset)) { + return vector2f(); + } + + vector2f v; + + for (uint32_t i = 0; i < 2; ++i) { + v[i] = iv[i]; + v[i] -= offset; + v[i] /= offset; + /* + switch(iv[i]) { + case 0: + v[i] = 0.0f; + break; + + case 1: + v[i] = 1.0f; + + break; + + case 2: + v[i] = -1.0f; + break; + } + */ + } + + if (v.length() > 1.0f) { + return ; + } + + /* + vector2f velocity = v.unit(); + return velocity; + */ +} +float communication::get_angular_velocity_rad_per_sec() const { + return 0.0f; +} +communication::vector2f communication::get_target_position_mm() const { + return vector2f(); +} +float communication::get_target_heading_rad() const { + return 0.0f; +}