Skip to content

Commit b6bd867

Browse files
committed
-
1 parent e2e4caa commit b6bd867

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

coderbot.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"move_tr_speed": "75", "move_fw_elapse": "1.5", "ctrl_move_motion": "yes", "show_page_program": "true", "load_at_start": "", "move_tr_elapse": "1", "sound_start": "$startup.mp3", "sound_stop": "$shutdown.mp3", "camera_exposure_mode": "auto", "prog_video_rec": "true", "show_control_move_commands": "true", "prog_level": "basic_move", "prog_scrollbars": "true", "ctrl_fw_speed": "100", "move_fw_speed": "100", "sound_shutter": "$shutter.mp3", "show_page_prefs": "true", "prog_maxblocks": "-1", "ctrl_hud_image": "coderbot_hud_2.png", "move_motor_mode": "dc", "ctrl_fw_elapse": "20", "ctrl_tr_elapse": "90", "show_page_control": "true", "ctrl_tr_speed": "80"}
1+
{"move_tr_speed": "75", "move_fw_elapse": "1.5", "show_page_program": "true", "load_at_start": "", "move_tr_elapse": "1", "sound_start": "$startup.mp3", "sound_stop": "$shutdown.mp3", "camera_exposure_mode": "auto", "prog_video_rec": "true", "show_control_move_commands": "true", "prog_level": "basic_move", "prog_scrollbars": "true", "ctrl_fw_speed": "100", "move_fw_speed": "100", "sound_shutter": "$shutter.mp3", "show_page_prefs": "true", "prog_maxblocks": "-1", "ctrl_hud_image": "coderbot_hud_2.png", "move_motor_mode": "dc", "ctrl_fw_elapse": "-1", "ctrl_tr_elapse": "-1", "show_page_control": "true", "ctrl_tr_speed": "80"}

static/js/blockly/blocks.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ Blockly.JavaScript['coderbot_moveForward'] = function(block) {
109109

110110
Blockly.Python['coderbot_moveForward'] = function(block) {
111111
// Generate Python for moving forward.
112-
return 'get_bot().forward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n';
112+
if(CODERBOT_PROG_MOVE_MOTION) {
113+
return 'get_motion().move(dist=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n';
114+
115+
} else {
116+
return 'get_bot().forward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n';
117+
}
113118
};
114119

115120
Blockly.Blocks['coderbot_moveBackward'] = {
@@ -136,7 +141,12 @@ Blockly.JavaScript['coderbot_moveBackward'] = function(block) {
136141

137142
Blockly.Python['coderbot_moveBackward'] = function(block) {
138143
// Generate Python for moving forward.
139-
return 'get_bot().backward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n';
144+
if(CODERBOT_PROG_MOVE_MOTION) {
145+
return 'get_motion().move(dist=' + (-CODERBOT_MOV_FW_DEF_ELAPSE) + ')\n';
146+
147+
} else {
148+
return 'get_bot().backward(speed=' + CODERBOT_MOV_FW_DEF_SPEED + ', elapse=' + CODERBOT_MOV_FW_DEF_ELAPSE + ')\n';
149+
}
140150
};
141151

142152
Blockly.Blocks['coderbot_turnLeft'] = {
@@ -163,7 +173,12 @@ Blockly.JavaScript['coderbot_turnLeft'] = function(block) {
163173

164174
Blockly.Python['coderbot_turnLeft'] = function(block) {
165175
// Generate Python for turning left.
166-
return 'get_bot().left(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n';
176+
if(CODERBOT_PROG_MOVE_MOTION) {
177+
return 'get_motion().turn(angle=' + (-CODERBOT_MOV_TR_DEF_ELAPSE) + ')\n';
178+
179+
} else {
180+
return 'get_bot().left(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n';
181+
}
167182
};
168183

169184
Blockly.Blocks['coderbot_turnRight'] = {
@@ -190,7 +205,12 @@ Blockly.JavaScript['coderbot_turnRight'] = function(block) {
190205

191206
Blockly.Python['coderbot_turnRight'] = function(block) {
192207
// Generate Python for turning left or right.
193-
return 'get_bot().right(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n';
208+
if(CODERBOT_PROG_MOVE_MOTION) {
209+
return 'get_motion().turn(angle=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n';
210+
211+
} else {
212+
return 'get_bot().right(speed=' + CODERBOT_MOV_TR_DEF_SPEED + ', elapse=' + CODERBOT_MOV_TR_DEF_ELAPSE + ')\n';
213+
}
194214
};
195215

196216
Blockly.Blocks['coderbot_say'] = {

templates/config.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ <h1>CoderBot</h1>
8787
<div id="t_movement" class="ui-body-d ui-content">
8888
<label for="i_move_motor_mode">{% trans %}Motor control mode{% endtrans %}</label>
8989
<input type="text" id="i_move_motor_mode" name="move_motor_mode" value="{{config.move_motor_mode}}">
90+
<div class="ui-field-contain">
91+
<label for="i_prog_move_mode">{% trans %}Movement assisted by vision{% endtrans %}</label>
92+
<input type="checkbox" data-role="flipswitch" id="i_prog_move_mode" name="prog_move_motion" value="yes"{%if config.prog_move_motion%} checked{%endif%}>
93+
</div>
9094
<label for="i_move_fw_speed">{% trans %}Forward speed{% endtrans %}</label>
9195
<input type="text" id="i_move_fw_speed" name="move_fw_speed" value="{{config.move_fw_speed}}">
9296
<label for="i_move_fw_elapse">{% trans %}Forward elapse{% endtrans %}</label>

templates/config_params.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var CODERBOT_MOV_FW_DEF_ELAPSE={{config.move_fw_elapse}};
44
var CODERBOT_MOV_TR_DEF_SPEED={{config.move_tr_speed}};
55
var CODERBOT_MOV_TR_DEF_ELAPSE={{config.move_tr_elapse}};
6+
var CODERBOT_PROG_MOVE_MOTION="{{config.prog_move_motion}}"=="yes";
67
var CODERBOT_STREAM_URL="http://{{host}}:{{stream_port}}/stream"
78
var CODERBOT_PROG_LEVEL="{{config.prog_level}}";
89
var CODERBOT_PROG_SCROLLBARS="{{config.prog_scrollbars}}"=="true";

0 commit comments

Comments
 (0)