Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ucbus-stepper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jake Read
ucbus-stepper
Commits
bc79029c
Commit
bc79029c
authored
2 years ago
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
api cleanup... velocity-set mode, halt
parent
2e3a727b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
firmware/axl-stepper/src/axl
+1
-1
1 addition, 1 deletion
firmware/axl-stepper/src/axl
firmware/axl-stepper/src/main.cpp
+39
-31
39 additions, 31 deletions
firmware/axl-stepper/src/main.cpp
with
40 additions
and
32 deletions
axl
@
09e3e906
Compare
0aa41982
...
09e3e906
Subproject commit 0
aa41982be0a8ec1189ec6e4517e4f1c2b6774cb
Subproject commit 0
9e3e90667034d09f34bbe4041b3f395461fad8a
This diff is collapsed.
Click to expand it.
firmware/axl-stepper/src/main.cpp
+
39
−
31
View file @
bc79029c
...
@@ -21,40 +21,39 @@ VBus_UCBusDrop vbUCBusDrop(&osap, "ucBusDrop");
...
@@ -21,40 +21,39 @@ VBus_UCBusDrop vbUCBusDrop(&osap, "ucBusDrop");
// -------------------------------------------------------- 2: States
// -------------------------------------------------------- 2: States
EP_ONDATA_RESPONSES
onStateData
(
uint8_t
*
data
,
uint16_t
len
){
EP_ONDATA_RESPONSES
onStateData
(
uint8_t
*
data
,
uint16_t
len
){
// check for partner-config badness,
if
(
len
!=
AXL_NUM_DOF
*
4
+
2
){
OSAP
::
error
(
"state req has bad DOF count"
);
return
EP_ONDATA_REJECT
;
}
// we have accel, rate, posn data,
// we have accel, rate, posn data,
dofs
targ
;
dofs
targ
;
uint16_t
rptr
=
0
;
uint16_t
rptr
=
0
;
uint8_t
mode
=
data
[
rptr
];
uint8_t
mode
=
data
[
rptr
++
];
if
(
mode
==
AXL_MODE_ACCEL
){
uint8_t
set
=
data
[
rptr
++
];
// read from 1st block of ndof
for
(
uint8_t
a
=
0
;
a
<
AXL_NUM_DOF
;
a
++
){
/*
targ
.
axis
[
a
]
=
ts_readFloat32
(
data
,
&
rptr
);
rptr = 1;
}
for(uint8_t a = 0; a < AXL_NUM_DOF; a ++){
// set or target?
targ.axis[a] = ts_readFloat32(data, &rptr);
if
(
set
){
}
if
(
mode
==
AXL_MODE_POSITION
){
axl_setAccelTarget(targ);
OSAP
::
error
(
"axl set-pos... havne't written it yet"
);
*/
}
else
{
}
else
if
(
mode
==
AXL_MODE_VELOCITY
){
OSAP
::
error
(
"we can only 'set' position, others are targs"
);
//axl_setVelocityTarget(rate.f);
rptr
=
1
+
AXL_NUM_DOF
*
4
*
1
;
for
(
uint8_t
a
=
0
;
a
<
AXL_NUM_DOF
;
a
++
){
targ
.
axis
[
a
]
=
ts_readFloat32
(
data
,
&
rptr
);
}
axl_setVelocityTarget
(
targ
);
}
else
if
(
mode
==
AXL_MODE_POSITION
){
rptr
=
1
+
AXL_NUM_DOF
*
4
*
2
;
for
(
uint8_t
a
=
0
;
a
<
AXL_NUM_DOF
;
a
++
){
targ
.
axis
[
a
]
=
ts_readFloat32
(
data
,
&
rptr
);
}
}
axl_setPositionTarget
(
targ
);
}
else
{
}
else
{
// no / bad mode set, noop
switch
(
mode
){
OSAP
::
error
(
"bad set-states request to axl, no / bad mode info"
,
MEDIUM
);
case
AXL_MODE_ACCEL
:
axl_setAccelTarget
(
targ
);
break
;
case
AXL_MODE_VELOCITY
:
axl_setVelocityTarget
(
targ
);
break
;
case
AXL_MODE_POSITION
:
axl_setPositionTarget
(
targ
);
break
;
default:
OSAP
::
error
(
"AXL state targ has bad / unrecognized mode"
);
break
;
}
}
}
// chunk_float32 acc = { .bytes = { data[0], data[1], data[2], data[3] } };
// chunk_float32 rate = { .bytes = { data[4], data[5], data[6], data[7] } };
// chunk_float32 posn = { .bytes = { data[8], data[9], data[10], data[11] } };
// we 'reject' this i.e. we don't write these data into the endpoint,
// since we routinely update it w/ actual states (not requests)
// since we routinely update it w/ actual states (not requests)
return
EP_ONDATA_REJECT
;
return
EP_ONDATA_REJECT
;
}
}
...
@@ -81,7 +80,16 @@ void updateStatesEP(void){
...
@@ -81,7 +80,16 @@ void updateStatesEP(void){
statesEP
.
write
(
stash
,
numBytes
);
statesEP
.
write
(
stash
,
numBytes
);
}
}
// -------------------------------------------------------- 3: Moves -> Queue
// -------------------------------------------------------- 3: Halt
EP_ONDATA_RESPONSES
onHaltData
(
uint8_t
*
data
,
uint16_t
len
){
axl_halt
();
return
EP_ONDATA_REJECT
;
}
Endpoint
haltEP
(
&
osap
,
"halt"
,
onHaltData
);
// -------------------------------------------------------- 4: Moves -> Queue
EP_ONDATA_RESPONSES
onMoveData
(
uint8_t
*
data
,
uint16_t
len
){
EP_ONDATA_RESPONSES
onMoveData
(
uint8_t
*
data
,
uint16_t
len
){
// this (and states-input) could watch <len> to make sure that
// this (and states-input) could watch <len> to make sure that
...
@@ -102,7 +110,7 @@ EP_ONDATA_RESPONSES onMoveData(uint8_t* data, uint16_t len){
...
@@ -102,7 +110,7 @@ EP_ONDATA_RESPONSES onMoveData(uint8_t* data, uint16_t len){
Endpoint
moveEP
(
&
osap
,
"moves"
,
onMoveData
);
Endpoint
moveEP
(
&
osap
,
"moves"
,
onMoveData
);
// --------------------------------------------------------
4
: AXL Settings
// --------------------------------------------------------
5
: AXL Settings
EP_ONDATA_RESPONSES
onAXLSettingsData
(
uint8_t
*
data
,
uint16_t
len
){
EP_ONDATA_RESPONSES
onAXLSettingsData
(
uint8_t
*
data
,
uint16_t
len
){
// jd, then pairs of accel & vel limits,
// jd, then pairs of accel & vel limits,
...
@@ -123,7 +131,7 @@ EP_ONDATA_RESPONSES onAXLSettingsData(uint8_t* data, uint16_t len){
...
@@ -123,7 +131,7 @@ EP_ONDATA_RESPONSES onAXLSettingsData(uint8_t* data, uint16_t len){
Endpoint
axlSettingsEP
(
&
osap
,
"axlSettings"
,
onAXLSettingsData
);
Endpoint
axlSettingsEP
(
&
osap
,
"axlSettings"
,
onAXLSettingsData
);
// --------------------------------------------------------
5
: Motor Settings
// --------------------------------------------------------
6
: Motor Settings
uint8_t
axisPick
=
0
;
uint8_t
axisPick
=
0
;
boolean
invert
=
false
;
boolean
invert
=
false
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment