Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jake Read
rndmc
Commits
38a5c2a2
Commit
38a5c2a2
authored
Dec 07, 2018
by
Jake Read
Browse files
ok radians conversion
parent
2cfe5959
Changes
4
Hide whitespace changes
Inline
Side-by-side
modules/hardware/atkmrobot.js
View file @
38a5c2a2
...
@@ -46,9 +46,9 @@ function ATKMathRobot() {
...
@@ -46,9 +46,9 @@ function ATKMathRobot() {
var
state
=
atkmr
.
state
var
state
=
atkmr
.
state
state
.
message
=
'
no packet yet
'
state
.
message
=
'
no packet yet
'
state
.
enc_cnt
=
16384
state
.
pc_t
=
2048
state
.
pc_t
=
2048
state
.
onUiChange
(
'
pc_t
'
,
onPositionTargetUserChange
)
state
.
onUiChange
(
'
pc_t
'
,
onPositionTargetUserChange
)
state
.
walk
=
1024
state
.
pKp
=
4.5
state
.
pKp
=
4.5
state
.
onUiChange
(
'
pKp
'
,
onKValsUpdate
)
state
.
onUiChange
(
'
pKp
'
,
onKValsUpdate
)
...
@@ -61,6 +61,8 @@ function ATKMathRobot() {
...
@@ -61,6 +61,8 @@ function ATKMathRobot() {
state
.
cKi
=
0.0
state
.
cKi
=
0.0
state
.
onUiChange
(
'
cKi
'
,
onKValsUpdate
)
state
.
onUiChange
(
'
cKi
'
,
onKValsUpdate
)
state
.
walk
=
1024
atkmr
.
ui
=
UI
()
atkmr
.
ui
=
UI
()
var
ui
=
atkmr
.
ui
var
ui
=
atkmr
.
ui
ui
.
addElement
(
'
walkValButton
'
,
'
./ui/uiButton.js
'
,
onPositionTickTock
)
ui
.
addElement
(
'
walkValButton
'
,
'
./ui/uiButton.js
'
,
onPositionTickTock
)
...
@@ -89,7 +91,9 @@ function ATKMathRobot() {
...
@@ -89,7 +91,9 @@ function ATKMathRobot() {
}
}
atkmr
.
route
.
subscribe
(
145
,
function
(
msg
){
atkmr
.
route
.
subscribe
(
145
,
function
(
msg
){
console
.
log
(
'
145 return
'
,
msg
)
var
pos
=
PCKT
.
unPack32
(
msg
.
slice
(
1
))
var
rads
=
2
*
Math
.
PI
*
(
pos
/
state
.
enc_cnt
)
atkmr
.
outputs
.
pos
.
emit
(
rads
)
})
})
function
onPositionTargetUserChange
()
{
function
onPositionTargetUserChange
()
{
...
...
modules/hardware/atkseriallink.js
View file @
38a5c2a2
...
@@ -29,6 +29,7 @@ function ATKSerialLink() {
...
@@ -29,6 +29,7 @@ function ATKSerialLink() {
state
.
portName
=
'
---
'
state
.
portName
=
'
---
'
state
.
portStatus
=
'
closed
'
// or we hope it will be
state
.
portStatus
=
'
closed
'
// or we hope it will be
state
.
log
=
true
atkSerialLink
.
ui
=
UI
()
atkSerialLink
.
ui
=
UI
()
var
ui
=
atkSerialLink
.
ui
var
ui
=
atkSerialLink
.
ui
...
@@ -117,12 +118,12 @@ function ATKSerialLink() {
...
@@ -117,12 +118,12 @@ function ATKSerialLink() {
pckt
=
literalRoute
.
concat
(
pckt
)
// add route
pckt
=
literalRoute
.
concat
(
pckt
)
// add route
pckt
.
unshift
(
pckt
.
length
+
1
)
// add length byte
pckt
.
unshift
(
pckt
.
length
+
1
)
// add length byte
if
(
writeToSerialPort
(
pckt
))
{
if
(
writeToSerialPort
(
pckt
))
{
console
.
log
(
'
PCKT OUT >>
'
,
pckt
.
toString
(),
'
---------------
'
)
if
(
state
.
log
)
console
.
log
(
'
PCKT OUT >>
'
,
pckt
.
toString
(),
'
---------------
'
)
}
else
{
}
else
{
// try to open ?
// try to open ?
openSerialPort
()
openSerialPort
()
if
(
writeToSerialPort
(
pckt
))
{
if
(
writeToSerialPort
(
pckt
))
{
console
.
log
(
'
PCKT OOT >>
'
,
pckt
.
toString
())
if
(
state
.
log
)
console
.
log
(
'
PCKT OOT >>
'
,
pckt
.
toString
())
}
else
{
}
else
{
console
.
log
(
'
LINK ERR: attempt to send to hardware, port not writable
'
)
console
.
log
(
'
LINK ERR: attempt to send to hardware, port not writable
'
)
}
}
...
@@ -198,7 +199,7 @@ function ATKSerialLink() {
...
@@ -198,7 +199,7 @@ function ATKSerialLink() {
// we're the last link, shift that pointer
// we're the last link, shift that pointer
shiftPacketPointer
(
pckt
)
shiftPacketPointer
(
pckt
)
// log it
// log it
console
.
log
(
'
PCKT IN <<
'
,
pckt
.
toString
(),
'
-----------------------
'
)
if
(
state
.
log
)
console
.
log
(
'
PCKT IN <<
'
,
pckt
.
toString
(),
'
-----------------------
'
)
// grab the routing header
// grab the routing header
var
incomingRoute
=
pckt
.
slice
(
2
,
pckt
.
indexOf
(
255
))
var
incomingRoute
=
pckt
.
slice
(
2
,
pckt
.
indexOf
(
255
))
// flip to match outgoing
// flip to match outgoing
...
...
robot.js
View file @
38a5c2a2
...
@@ -8,6 +8,7 @@ var program = Programs.new('new program')
...
@@ -8,6 +8,7 @@ var program = Programs.new('new program')
var
link
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkseriallink.js
'
)
var
link
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkseriallink.js
'
)
link
.
startUp
()
link
.
startUp
()
link
.
state
.
log
=
false
Programs
.
setUI
(
link
,
1050
,
50
)
Programs
.
setUI
(
link
,
1050
,
50
)
var
mrbot
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkmrobot.js
'
)
var
mrbot
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkmrobot.js
'
)
...
@@ -28,6 +29,7 @@ delay.outputs.out.attach(gate.inputs.thru)
...
@@ -28,6 +29,7 @@ delay.outputs.out.attach(gate.inputs.thru)
gate
.
outputs
.
out
.
attach
(
button
.
inputs
.
thru
)
gate
.
outputs
.
out
.
attach
(
button
.
inputs
.
thru
)
var
log
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/util/log.js
'
)
var
log
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/util/log.js
'
)
log
.
state
.
prefix
=
"
jnt1:
"
Programs
.
setUI
(
log
,
840
,
520
)
Programs
.
setUI
(
log
,
840
,
520
)
mrbot
.
outputs
.
pos
.
attach
(
log
.
inputs
.
thru
)
mrbot
.
outputs
.
pos
.
attach
(
log
.
inputs
.
thru
)
...
...
views.js
View file @
38a5c2a2
...
@@ -19,6 +19,7 @@ SERVER AND WS SETUP --------------------------------------------------
...
@@ -19,6 +19,7 @@ SERVER AND WS SETUP --------------------------------------------------
var
program
=
null
var
program
=
null
var
sckt
=
null
var
sckt
=
null
var
verbose
=
false
function
startHttp
()
{
function
startHttp
()
{
// serving this handful of static files
// serving this handful of static files
...
@@ -291,13 +292,13 @@ function uiRequestLinkChange(data) {
...
@@ -291,13 +292,13 @@ function uiRequestLinkChange(data) {
}
}
function
uiRequestUiChange
(
data
){
function
uiRequestUiChange
(
data
){
console
.
log
(
'
UI PUSH UI DATA DOWN
'
,
data
)
if
(
verbose
)
console
.
log
(
'
UI PUSH UI DATA DOWN
'
,
data
)
var
mdlUiElem
=
program
.
modules
[
data
.
id
].
ui
[
data
.
key
]
var
mdlUiElem
=
program
.
modules
[
data
.
id
].
ui
[
data
.
key
]
mdlUiElem
.
onMessage
(
data
.
msg
)
mdlUiElem
.
onMessage
(
data
.
msg
)
}
}
function
uiRequestMdlPositionChange
(
data
)
{
function
uiRequestMdlPositionChange
(
data
)
{
console
.
log
(
'
UI REQUEST ADD / CHANGE UI INFO TO MODULE
'
,
data
)
if
(
verbose
)
console
.
log
(
'
UI REQUEST ADD / CHANGE UI INFO TO MODULE
'
,
data
)
var
mod
=
program
.
modules
[
data
.
description
.
id
]
var
mod
=
program
.
modules
[
data
.
description
.
id
]
mod
.
description
.
position
=
data
.
description
.
position
mod
.
description
.
position
=
data
.
description
.
position
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment