-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add headings and other geometric pins in motion using State_tags #3995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 22 commits
5a8e0d9
cac77e5
52572e5
da9fa18
12d2cc2
d4f3a18
00450b3
1321309
7ae6979
8a869ec
2702760
7c6f016
8413344
245e91b
de27899
7021690
20992b0
5b2d61f
5461c2d
bafea85
b576a1f
ecb5799
d61aea7
34af536
37bd9ba
026421b
aa3f8e3
892b9a3
4fc14bc
8560dac
81e061d
d707137
2d9030a
cbc2c6d
9d7b041
b79afe5
90a6c94
87a2fb2
28395da
697ac51
44bf837
01dba4d
b700943
b59c583
d0d7143
43c1a2a
f030b39
0b572ff
043af1f
f9e9707
3e3ac4f
39a2445
1305055
82cc7f0
c608d9f
b4e3848
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,14 +26,15 @@ | |
| #include <posemath.h> | ||
| #include <kinematics.h> //for kinematicsSwitchable() | ||
| #include <motion_types.h> | ||
|
|
||
| #include "../tp/tp.h" | ||
| #include "simple_tp.h" | ||
| #include "motion.h" | ||
| #include "mot_priv.h" | ||
| #include "config.h" | ||
| #include "homing.h" | ||
| #include "axis.h" | ||
| #include "state_tag.h" | ||
|
|
||
|
|
||
| // Mark strings for translation, but defer translation to userspace | ||
| #define _(s) (s) | ||
|
|
@@ -1888,6 +1889,20 @@ static void output_to_hal(void) | |
| *(emcmot_hal_data->coord_error) = GET_MOTION_ERROR_FLAG(); | ||
| *(emcmot_hal_data->on_soft_limit) = emcmotStatus->on_soft_limit; | ||
|
|
||
| /* Update the HAL Output Pins from the active tag */ | ||
| /* Geometric Metadata */ | ||
| *(emcmot_hal_data->interp_arc_radius) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_RADIUS]; | ||
| *(emcmot_hal_data->interp_arc_center_x) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_X]; | ||
| *(emcmot_hal_data->interp_arc_center_y) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_Y]; | ||
| *(emcmot_hal_data->interp_straight_heading) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_STRAIGHT_HEADING]; | ||
|
|
||
| /* Performance Metadata */ | ||
| *(emcmot_hal_data->interp_feedrate) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_FEED]; | ||
|
|
||
| /* Line and Motion Type (Casting to int for s32 HAL pins) */ | ||
| *(emcmot_hal_data->interp_line_number) = (int)emcmotStatus->tag.fields[GM_FIELD_LINE_NUMBER]; | ||
| *(emcmot_hal_data->interp_motion_type) = (int)emcmotStatus->tag.fields[GM_FIELD_MOTION_MODE]; | ||
| *(emcmot_hal_data->iscircle) = (hal_bit_t)((emcmotStatus->tag.packed_flags & (1UL << GM_FLAG_IS_CIRCLE)) != 0); | ||
| switch (emcmotStatus->motionType) { | ||
| case EMC_MOTION_TYPE_FEED: //fall thru | ||
| case EMC_MOTION_TYPE_ARC: | ||
|
|
@@ -2033,10 +2048,8 @@ static void output_to_hal(void) | |
| /* point to joint struct */ | ||
| joint = &joints[joint_num]; | ||
| joint_data = &(emcmot_hal_data->joint[joint_num]); | ||
|
|
||
| /* apply backlash and motor offset to output */ | ||
| joint->motor_pos_cmd = | ||
| joint->pos_cmd + joint->backlash_filt + joint->motor_offset; | ||
|
BsAtHome marked this conversation as resolved.
|
||
| joint->motor_pos_cmd = joint->pos_cmd + joint->backlash_filt + joint->motor_offset; | ||
| /* point to HAL data */ | ||
| /* write to HAL pins */ | ||
| *(joint_data->motor_offset) = joint->motor_offset; | ||
|
|
@@ -2131,6 +2144,9 @@ static void update_status(void) | |
| // and the state machine is still active. The homing status deassertion | ||
| // must be delayed until the state machine is done. | ||
| joint_status->homing = get_homing(joint_num); | ||
| /* check to see if we should pause in order to implement | ||
| single emcmotStatus->stepping */ | ||
|
|
||
| } | ||
| joint_status->homed = get_homed(joint_num); | ||
| joint_status->pos_cmd = joint->pos_cmd; | ||
|
|
@@ -2211,6 +2227,78 @@ static void update_status(void) | |
| emcmotStatus->stepping = 0; | ||
| emcmotStatus->paused = 1; | ||
| } | ||
| // State Tags handling | ||
| // Get the current executing trajectory component (the "Source of Truth") | ||
| /* Update the HAL Output Pins from the active tag */ | ||
| if (emcmot_hal_data) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you testing for This same function derefences that exact same variable and does not check. So, the check is superfluous and creates a false sense of guard. The whole containing if() construct is redundant.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a mess of spaces and tabs, went with spaces on my stuff |
||
| // Line and Motion Type | ||
| if (emcmot_hal_data->interp_line_number) { | ||
| *(emcmot_hal_data->interp_line_number) = (int)emcmotStatus->tag.fields[GM_FIELD_LINE_NUMBER]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two issues:
|
||
| } | ||
|
|
||
| // Performance Metadata | ||
| if (emcmot_hal_data->interp_feedrate) { | ||
| *(emcmot_hal_data->interp_feedrate) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_FEED]; | ||
| } | ||
|
|
||
| // Geometric Metadata | ||
|
|
||
| if (emcmot_hal_data->interp_arc_radius) { | ||
| *(emcmot_hal_data->interp_arc_radius) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_RADIUS]; | ||
| } | ||
| if (emcmot_hal_data->interp_arc_center_x) { | ||
| *(emcmot_hal_data->interp_arc_center_x) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_X]; | ||
| } | ||
| if (emcmot_hal_data->interp_arc_center_y) { | ||
| *(emcmot_hal_data->interp_arc_center_y) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_Y]; | ||
| } | ||
| // Get the current motion type from the tag (1=G1, 2=G2, 3=G3) | ||
| int motion_type = (int)emcmotStatus->tag.fields[GM_FIELD_MOTION_MODE]; | ||
| if (motion_type == 10 || motion_type == 0) { | ||
| /* --- G1: STATIC HEADING --- */ | ||
| // For linear moves, the heading doesn't change during the segment. | ||
| if (emcmot_hal_data->interp_straight_heading) { | ||
| *(emcmot_hal_data->interp_straight_heading) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_STRAIGHT_HEADING]; | ||
| } | ||
| } | ||
| else if (motion_type == 20 || motion_type == 30) { | ||
| /* --- G2/G3: DYNAMIC ARC HEADING --- */ | ||
| double cx = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_X]; | ||
| double cy = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_ARC_CENTER_Y]; | ||
| *(emcmot_hal_data->iscircle) = (hal_bit_t)((emcmotStatus->tag.packed_flags & (1UL << GM_FLAG_IS_CIRCLE)) != 0); | ||
| // Current RT feedback position | ||
| double dx = emcmotStatus->carte_pos_fb.tran.x - cx; | ||
| double dy = emcmotStatus->carte_pos_fb.tran.y - cy; | ||
| double angle_rad = atan2(dy, dx); | ||
| // Normal heading is tool-to-centre (opposite of radial) | ||
| double normal_heading_deg = (angle_rad * (180.0 / M_PI)) + 180.0; | ||
| while (normal_heading_deg < 0) normal_heading_deg += 360.0; | ||
| while (normal_heading_deg >= 360.0) normal_heading_deg -= 360.0; | ||
| *(emcmot_hal_data->interp_normal_heading) = normal_heading_deg; | ||
|
|
||
| double heading_deg; | ||
|
|
||
| // G3 (CCW): Heading is Radial Angle + 90 degrees | ||
| if (motion_type == 30) { | ||
| heading_deg = (angle_rad + (M_PI / 2.0)) * (180.0 / M_PI); | ||
| } | ||
| // G2 (CW): Heading is Radial Angle - 90 degrees | ||
| else { | ||
| heading_deg = (angle_rad - (M_PI / 2.0)) * (180.0 / M_PI); | ||
| } | ||
| // 0-360 Normalization | ||
| while (heading_deg < 0) heading_deg += 360.0; | ||
| while (heading_deg >= 360.0) heading_deg -= 360.0; | ||
|
|
||
| // Now assign the calculated value | ||
| if (emcmot_hal_data->interp_straight_heading) | ||
| *(emcmot_hal_data->interp_straight_heading) = heading_deg; | ||
| // Performance Metadata | ||
| if (emcmot_hal_data->interp_feedrate) { | ||
| *(emcmot_hal_data->interp_feedrate) = emcmotStatus->tag.fields_float[GM_FIELD_FLOAT_FEED]; | ||
| } | ||
| } | ||
| } | ||
| #ifdef WATCH_FLAGS | ||
| /*! \todo FIXME - this is for debugging */ | ||
| if ( old_motion_flag != emcmotStatus->motionFlag ) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.