Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SimpleMapSerialization serial_communication
Revision 2:074942a78af1, committed 2016-04-03
- Comitter:
- inst
- Date:
- Sun Apr 03 06:30:39 2016 +0000
- Parent:
- 1:0970a7b78c1d
- Child:
- 3:41100e52d11d
- Commit message:
Changed in this revision
--- a/communication.cpp Thu Mar 31 04:43:55 2016 +0000
+++ b/communication.cpp Sun Apr 03 06:30:39 2016 +0000
@@ -3,11 +3,12 @@
#include "serial_communication.hpp"
#include "mbed_stl.hpp"
-
-
#include "mbed.h"
communication* communication::instance_ = NULL;
+const int communication::velocity_offset_ = 32767;
+
+communication::communication() {}
node_system::moving_object::CONTROL_MODE communication::get_mode() const {
return node_system::moving_object::MANUAL_MODE;
@@ -15,14 +16,12 @@
communication::vector2f communication::get_velocity() const {
uint32_t iv[] = {
- serial_communication::instance()->get_data("stkLX"),
- serial_communication::instance()->get_data("stkLY")
+ serial_communication::instance()->get("stkLX"),
+ serial_communication::instance()->get("stkLY")
};
// 受信データは [0, 65535] の範囲であるので [-1, 1] に変換する
- int offset = 32767;
-
- if ((iv[0] == offset) && (iv[1] == offset)) {
+ if ((iv[0] == velocity_offset_) && (iv[1] == velocity_offset_)) {
return vector2f();
}
@@ -30,8 +29,8 @@
for (uint32_t i = 0; i < 2; ++i) {
v[i] = iv[i];
- v[i] -= offset;
- v[i] /= offset;
+ v[i] -= velocity_offset_;
+ v[i] /= velocity_offset_;
/*
switch(iv[i]) {
case 0:
@@ -51,9 +50,11 @@
}
if (v.length() > 1.0f) {
- return ;
+ return v.unit();
}
+ return v;
+
/*
vector2f velocity = v.unit();
return velocity;
--- a/communication.hpp Thu Mar 31 04:43:55 2016 +0000
+++ b/communication.hpp Sun Apr 03 06:30:39 2016 +0000
@@ -7,6 +7,8 @@
class communication {
public:
typedef mbed_stl::linear_algebra::vector2f vector2f;
+
+ static const int velocity_offset_;
static communication* instance() {
if (instance_ == NULL) {
@@ -19,12 +21,12 @@
}
node_system::moving_object::CONTROL_MODE get_mode() const;
vector2f get_velocity() const;
- float get_angular_velocity_rad_per_sec() const;
+ float get_angular_velocity_rad_per_sec() const;
vector2f get_target_position_mm() const;
- float get_target_heading_rad() const;
+ float get_target_heading_rad() const;
private:
- communication() {}
+ communication();
~communication() {}
// singletonにつき禁止のため以下の二つの実装は無し
void operator=(const communication& s);
--- a/serial_communication.lib Thu Mar 31 04:43:55 2016 +0000 +++ b/serial_communication.lib Sun Apr 03 06:30:39 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/inst/code/serial_communication/#964bbeb0a1d3 +https://developer.mbed.org/users/inst/code/serial_communication/#36cd04f61e68