Emergency stop functionality implemented. Tuning to output values 26/187826/2
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Tue, 28 Aug 2018 18:35:05 +0000 (20:35 +0200)
committerMichal Skorupinski <m.skorupinsk@samsung.com>
Thu, 30 Aug 2018 13:35:52 +0000 (15:35 +0200)
Change-Id: Ib397a56540b13a1614075080b608f2e4c37cfd46
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
.cproject
inc/controller/controller_racing.h
inc/model/model_car_connection.h
src/controller/controller_racing.c
src/controller/controller_reset.c
src/model/model_car_connection.c
src/model/model_hw.c
src/view/view_racing.c

index b0c5037..e7dd90c 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -43,7 +43,7 @@
                                                                                
                             <builder autoBuildTarget="all" buildPath="${workspace_loc:/gear-racing-controller}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.227410736" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
                                                                                
-                            <tool command="i586-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1679874459" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+                            <tool command="arm-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1679874459" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
                                                                                
                             <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1354257060" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                                                
@@ -55,7 +55,7 @@
                                                                                                
                                 <option id="sbi.gnu.cpp.compiler.option.912899474" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
                                                                                                        
-                                    <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
+                                    <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm40.armel"/>
                                                                                                
                                 </option>
                                                                                                
                                     <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                                                        
                                     <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                                                       
+                                    <listOptionValue builtIn="false" value="-mthumb"/>
                                                                                                
                                 </option>
                                                                                                
                                                                                                
                                 <option id="sbi.gnu.c.compiler.option.1123455384" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
                                                                                                        
-                                    <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
+                                    <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm40.armel"/>
                                                                                                
                                 </option>
                                                                                                
                                     <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                                                        
                                     <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                                                       
+                                    <listOptionValue builtIn="false" value="-mthumb"/>
                                                                                                
                                 </option>
                                                                                                
index 943911b..20e4214 100644 (file)
@@ -29,5 +29,6 @@ void controller_racing_init(t_view_update_cb view_update_cb);
 void controller_racing_destroy(void);
 void controller_racing_back(void);
 void controller_racing_next();
+void controller_racing_set_stop(bool stop);
 
 #endif /* CONTROLLER_CONTROLLER_RACING_H_ */
index 372a4ae..a39c2e8 100644 (file)
@@ -37,6 +37,6 @@ void model_car_connection_end_connection(void);
 void model_car_connection_send_direction(float direction);
 void model_car_connection_send_throttle(float throttle);
 void model_car_connection_ready_to_drive(bool is_ready);
-
+void model_car_connection_set_stop(bool stop);
 
 #endif /* MODEL_MODEL_CAR_CONNECTION_H_ */
index e88538f..20a217a 100644 (file)
@@ -52,6 +52,11 @@ static void _hw_cb(s_model_hw_cb_data *model_data)
        s_info.base_controller.view_update_cb(&s_info.controller_data);
 }
 
+void controller_racing_set_stop(bool stop)
+{
+       model_car_connection_set_stop(stop);
+}
+
 void controller_racing_init(t_view_update_cb view_update_cb)
 {
        s_info.base_controller.view_update_cb = view_update_cb;
index 1e905f3..be69227 100644 (file)
@@ -27,9 +27,9 @@ static s_controller s_info = {  0, };
 void controller_reset_destroy(void)
 {
        model_cloud_connection_unsubscirbe_event();
+       model_car_connection_unsubscirbe_event();
 
        model_car_connection_end_connection();
-       model_car_connection_unsubscirbe_event();
 }
 
 static void _connected_cb(s_model_cloud_connection_cb_data *model_data)
index 53d7ffa..51c0c0d 100644 (file)
@@ -25,7 +25,7 @@
 #include "model/model_car_connection.h"
 #include "log.h"
 
-#define BASE_VALUE 100
+#define BASE_VALUE 1000
 #define HELLO_TIMER_WAIT 3.0
 
 typedef enum  _e_message_type {
@@ -58,6 +58,9 @@ typedef struct _s_car_model_connection {
 
        float direction;
        float throttle;
+       bool stop;
+
+       Ecore_Timer *send_timer;
 } s_model_car_connection;
 
 s_model_car_connection s_info = { 0, };
@@ -134,14 +137,14 @@ static void _send_data(int command, int servo, int speed)
        GError *error = NULL;
        static s_message message = { 0, };
 
-       _D("Send CMD[%d], Servo[%d], Speed[%d]", message.cmd, message.servo, message.speed);
-
        message.cmd = command;
        message.servo = servo;
        message.speed = speed;
        message.seq_num++;
        message.time = time(NULL);
 
+       _D("Send CMD[%d], Servo[%d], Speed[%d]", message.cmd, message.servo, message.speed);
+
        ASSERT(!s_info.socket, "Socket not created");
        ASSERT(!s_info.car_address, "Destination not set");
 
@@ -182,6 +185,18 @@ static Eina_Bool _connection_wait_timer_cb(void *data)
        return renew;
 }
 
+static Eina_Bool _send_timer_cb(void *data)
+{
+       if (s_info.stop) {
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       _D("DATA: %f %f", s_info.direction, s_info.throttle);
+       _send_data(MESSAGE_DRIVE, s_info.direction * -BASE_VALUE, s_info.throttle * 4095);
+
+       return ECORE_CALLBACK_RENEW;
+}
+
 
 void model_car_connection_init(void)
 {
@@ -235,6 +250,8 @@ void model_car_connection_start_connection(char *address, int port)
 
 //     s_info.controller_update_cb(&model_data);
 
+       s_info.send_timer = ecore_timer_add(1.0 / 60.0, _send_timer_cb, NULL);
+
        if (error) {
                g_error_free(error);
        }
@@ -260,25 +277,36 @@ void model_car_connection_end_connection(void)
        if (error) {
                g_error_free(error);
        }
+
+       ecore_timer_del(s_info.send_timer);
 }
 
 void model_car_connection_send_direction(float direction)
 {
-       if (!s_info.ready_to_drive) {
+       if (!s_info.ready_to_drive || s_info.stop) {
                return;
        }
 
        s_info.direction = direction;
-       _send_data(MESSAGE_DRIVE, s_info.direction * -BASE_VALUE, s_info.throttle * -BASE_VALUE);
+//     _send_data(MESSAGE_DRIVE, s_info.direction * -BASE_VALUE, s_info.throttle * -BASE_VALUE);
 }
 
 void model_car_connection_send_throttle(float throttle)
 {
-       if (!s_info.ready_to_drive) {
+       if (!s_info.ready_to_drive || s_info.stop) {
                return;
        }
 
        s_info.throttle = throttle;
-       _send_data(MESSAGE_DRIVE, s_info.direction * -BASE_VALUE, s_info.throttle * -BASE_VALUE);
+//     _send_data(MESSAGE_DRIVE, s_info.direction * -BASE_VALUE, s_info.throttle * -BASE_VALUE);
+}
+
+void model_car_connection_set_stop(bool stop)
+{
+       s_info.stop = stop;
+
+       if (stop) {
+               _send_data(MESSAGE_DRIVE, 0, 0);
+       }
 }
 
index 4fe21ef..f69561f 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "log.h"
 
-#define THROTTLE_STEP 0.01
+#define THROTTLE_STEP 0.03
 
 typedef struct _s_model_hw {
        t_model_hw_update_cb hw_update_cb;
index 0dc6200..a883ba9 100644 (file)
@@ -101,6 +101,8 @@ void _racing_screen_clicked_cb(void *data, Evas_Object *obj, const char *emissio
 {
        evas_object_hide(s_info.velocity);
        evas_object_hide(s_info.direction);
+
+       controller_racing_set_stop(true);
 }
 
 void _stop_longpress_completed(void *data, Evas_Object *obj, const char *emission, const char *source)
@@ -124,6 +126,8 @@ void _stop_logpress_up(void *data, Evas_Object *obj, const char *emission, const
        }
 
        s_info.stop_longpress = false;
+
+       controller_racing_set_stop(false);
        ASSERT_FUNCTION_END;
 }
 
@@ -147,6 +151,8 @@ static void _view_racing_create_gui(Evas_Object *parent)
 
        elm_layout_signal_callback_add(s_info.view_base.view, "stop_pressed", "", _stop_longpress_completed, NULL);
        elm_layout_signal_callback_add(s_info.view_base.view, "stop_released", "", _stop_logpress_up, NULL);
+
+       controller_racing_set_stop(false);
 }
 
 static void _show_cb(void)