From 0b804a4100267955e56fd1267af946f74f05a626 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Wed, 2 Jan 2013 11:37:14 +1100 Subject: [PATCH] Robot: change defaults to better suit smoothieboard, some whitespace changes, delete old arm_solution if we get a new one for some reason --- src/modules/robot/Robot.cpp | 68 +++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/modules/robot/Robot.cpp b/src/modules/robot/Robot.cpp index a2348c1b..3dcb7bb8 100644 --- a/src/modules/robot/Robot.cpp +++ b/src/modules/robot/Robot.cpp @@ -27,11 +27,11 @@ Robot::Robot(){ this->select_plane(X_AXIS, Y_AXIS, Z_AXIS); clear_vector(this->current_position); clear_vector(this->last_milestone); + this->arm_solution = NULL; } //Called when the module has just been loaded void Robot::on_module_loaded() { - this->arm_solution = new CartesianSolution(this->kernel->config); this->register_for_event(ON_GCODE_RECEIVED); // Configuration @@ -45,23 +45,26 @@ void Robot::on_module_loaded() { } void Robot::on_config_reload(void* argument){ - this->feed_rate = this->kernel->config->value(default_feed_rate_checksum )->by_default(100)->as_number()/60; - this->seek_rate = this->kernel->config->value(default_seek_rate_checksum )->by_default(100)->as_number()/60; - this->mm_per_line_segment = this->kernel->config->value(mm_per_line_segment_checksum)->by_default(0.1)->as_number(); - this->mm_per_arc_segment = this->kernel->config->value(mm_per_arc_segment_checksum )->by_default(10 )->as_number(); - this->arc_correction = this->kernel->config->value(arc_correction_checksum )->by_default(5 )->as_number(); - this->max_speeds[X_AXIS] = this->kernel->config->value(x_axis_max_speed_checksum )->by_default(0 )->as_number(); - this->max_speeds[Y_AXIS] = this->kernel->config->value(y_axis_max_speed_checksum )->by_default(0 )->as_number(); - this->max_speeds[Z_AXIS] = this->kernel->config->value(z_axis_max_speed_checksum )->by_default(0 )->as_number(); - this->alpha_step_pin = this->kernel->config->value(alpha_step_pin_checksum )->by_default("1.21" )->as_pin()->as_output(); - this->beta_step_pin = this->kernel->config->value(beta_step_pin_checksum )->by_default("1.23" )->as_pin()->as_output(); - this->gamma_step_pin = this->kernel->config->value(gamma_step_pin_checksum )->by_default("1.22!" )->as_pin()->as_output(); - this->alpha_dir_pin = this->kernel->config->value(alpha_dir_pin_checksum )->by_default("1.18" )->as_pin()->as_output(); - this->beta_dir_pin = this->kernel->config->value(beta_dir_pin_checksum )->by_default("1.20" )->as_pin()->as_output(); - this->gamma_dir_pin = this->kernel->config->value(gamma_dir_pin_checksum )->by_default("1.19" )->as_pin()->as_output(); - this->alpha_en_pin = this->kernel->config->value(alpha_en_pin_checksum )->by_default("0.4" )->as_pin()->as_output()->as_open_drain(); - this->beta_en_pin = this->kernel->config->value(beta_en_pin_checksum )->by_default("0.10" )->as_pin()->as_output()->as_open_drain(); - this->gamma_en_pin = this->kernel->config->value(gamma_en_pin_checksum )->by_default("0.19" )->as_pin()->as_output()->as_open_drain(); + if (this->arm_solution) delete this->arm_solution; + this->arm_solution = new CartesianSolution(this->kernel->config); + + this->feed_rate = this->kernel->config->value(default_feed_rate_checksum )->by_default(100 )->as_number() / 60; + this->seek_rate = this->kernel->config->value(default_seek_rate_checksum )->by_default(100 )->as_number() / 60; + this->mm_per_line_segment = this->kernel->config->value(mm_per_line_segment_checksum )->by_default(5.0 )->as_number(); + this->mm_per_arc_segment = this->kernel->config->value(mm_per_arc_segment_checksum )->by_default(0.5 )->as_number(); + this->arc_correction = this->kernel->config->value(arc_correction_checksum )->by_default(5 )->as_number(); + this->max_speeds[X_AXIS] = this->kernel->config->value(x_axis_max_speed_checksum )->by_default(60000 )->as_number(); + this->max_speeds[Y_AXIS] = this->kernel->config->value(y_axis_max_speed_checksum )->by_default(60000 )->as_number(); + this->max_speeds[Z_AXIS] = this->kernel->config->value(z_axis_max_speed_checksum )->by_default(300 )->as_number(); + this->alpha_step_pin = this->kernel->config->value(alpha_step_pin_checksum )->by_default("2.0" )->as_pin()->as_output(); + this->beta_step_pin = this->kernel->config->value(beta_step_pin_checksum )->by_default("2.1" )->as_pin()->as_output(); + this->gamma_step_pin = this->kernel->config->value(gamma_step_pin_checksum )->by_default("2.2" )->as_pin()->as_output(); + this->alpha_dir_pin = this->kernel->config->value(alpha_dir_pin_checksum )->by_default("0.5" )->as_pin()->as_output(); + this->beta_dir_pin = this->kernel->config->value(beta_dir_pin_checksum )->by_default("0.11" )->as_pin()->as_output(); + this->gamma_dir_pin = this->kernel->config->value(gamma_dir_pin_checksum )->by_default("0.20" )->as_pin()->as_output(); + this->alpha_en_pin = this->kernel->config->value(alpha_en_pin_checksum )->by_default("0.4" )->as_pin()->as_output()->as_open_drain(); + this->beta_en_pin = this->kernel->config->value(beta_en_pin_checksum )->by_default("0.10" )->as_pin()->as_output()->as_open_drain(); + this->gamma_en_pin = this->kernel->config->value(gamma_en_pin_checksum )->by_default("0.19" )->as_pin()->as_output()->as_open_drain(); } @@ -83,7 +86,6 @@ void Robot::on_gcode_received(void * argument){ this->execute_gcode(gcode); block->append_gcode(gcode); } - } @@ -95,20 +97,20 @@ void Robot::execute_gcode(Gcode* gcode){ this->motion_mode = -1; //G-letter Gcodes are mostly what the Robot module is interrested in, other modules also catch the gcode event and do stuff accordingly - if( gcode->has_letter('G')){ - switch( (int) gcode->get_value('G') ){ - case 0: this->motion_mode = MOTION_MODE_SEEK; break; - case 1: this->motion_mode = MOTION_MODE_LINEAR; break; - case 2: this->motion_mode = MOTION_MODE_CW_ARC; break; - case 3: this->motion_mode = MOTION_MODE_CCW_ARC; break; - case 17: this->select_plane(X_AXIS, Y_AXIS, Z_AXIS); break; - case 18: this->select_plane(X_AXIS, Z_AXIS, Y_AXIS); break; - case 19: this->select_plane(Y_AXIS, Z_AXIS, X_AXIS); break; - case 20:this->inch_mode = true; break; - case 21:this->inch_mode = false; break; - case 90:this->absolute_mode = true; break; - case 91:this->absolute_mode = false; break; - case 92: { + if( gcode->has_letter('G')){ + switch( (int) gcode->get_value('G') ){ + case 0: this->motion_mode = MOTION_MODE_SEEK; break; + case 1: this->motion_mode = MOTION_MODE_LINEAR; break; + case 2: this->motion_mode = MOTION_MODE_CW_ARC; break; + case 3: this->motion_mode = MOTION_MODE_CCW_ARC; break; + case 17: this->select_plane(X_AXIS, Y_AXIS, Z_AXIS); break; + case 18: this->select_plane(X_AXIS, Z_AXIS, Y_AXIS); break; + case 19: this->select_plane(Y_AXIS, Z_AXIS, X_AXIS); break; + case 20: this->inch_mode = true; break; + case 21: this->inch_mode = false; break; + case 90: this->absolute_mode = true; break; + case 91: this->absolute_mode = false; break; + case 92: { if(gcode->get_num_args() == 0){ for (char letter = 'X'; letter <= 'Z'; letter++){ if ( gcode->has_letter(letter) ) -- 2.20.1