Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
robotis_motion_pages
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
humanoides
robotis_motion_pages
Commits
fe6b475e
Commit
fe6b475e
authored
11 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Corrected the computation of the page checksum.
parent
89437da9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/bioloid_motion_pages.cpp
+30
-25
30 additions, 25 deletions
src/bioloid_motion_pages.cpp
src/stm32_src_mtn.cpp
+12
-7
12 additions, 7 deletions
src/stm32_src_mtn.cpp
src/stm32_src_mtn.h
+1
-1
1 addition, 1 deletion
src/stm32_src_mtn.h
with
43 additions
and
33 deletions
src/bioloid_motion_pages.cpp
+
30
−
25
View file @
fe6b475e
...
...
@@ -51,34 +51,39 @@ int main(const int argc,char *argv[])
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
}
}
/* show motion pages */
std
::
cout
<<
"Num. pages: "
<<
motions
.
get_num_pages
()
<<
std
::
endl
;
for
(
i
=
0
;
i
<
motions
.
get_num_pages
();
i
++
)
{
page
=
motions
.
get_page
(
i
);
std
::
cout
<<
"name: "
<<
page
.
get_name
()
<<
std
::
endl
;
std
::
cout
<<
"next page: "
<<
page
.
get_next_page
()
<<
std
::
endl
;
std
::
cout
<<
"exit page: "
<<
page
.
get_exit_page
()
<<
std
::
endl
;
std
::
cout
<<
"repetitions: "
<<
page
.
get_repetitions
()
<<
std
::
endl
;
std
::
cout
<<
"speed rate: "
<<
page
.
get_speed_rate
()
<<
std
::
endl
;
std
::
cout
<<
"inertial force: "
<<
page
.
get_inertial
()
<<
std
::
endl
;
std
::
cout
<<
"Num. steps: "
<<
page
.
get_num_steps
()
<<
std
::
endl
;
for
(
j
=
0
;
j
<
page
.
get_num_steps
();
j
++
)
try
{
/* show motion pages */
std
::
cout
<<
"Num. pages: "
<<
motions
.
get_num_pages
()
<<
std
::
endl
;
for
(
i
=
0
;
i
<
motions
.
get_num_pages
();
i
++
)
{
step
=
page
.
get_step
(
j
);
std
::
cout
<<
"angles: "
;
angles
=
step
.
get_angles
();
for
(
k
=
0
;
k
<
angles
.
size
();
k
++
)
std
::
cout
<<
angles
[
k
]
<<
","
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"pausetime: "
<<
step
.
get_pause_time
()
<<
std
::
endl
;
std
::
cout
<<
"step time: "
<<
step
.
get_step_time
()
<<
std
::
endl
;
std
::
cout
<<
i
<<
std
::
endl
;
page
=
motions
.
get_page
(
i
);
std
::
cout
<<
"name: "
<<
page
.
get_name
()
<<
std
::
endl
;
std
::
cout
<<
"next page: "
<<
page
.
get_next_page
()
<<
std
::
endl
;
std
::
cout
<<
"exit page: "
<<
page
.
get_exit_page
()
<<
std
::
endl
;
std
::
cout
<<
"repetitions: "
<<
page
.
get_repetitions
()
<<
std
::
endl
;
std
::
cout
<<
"speed rate: "
<<
page
.
get_speed_rate
()
<<
std
::
endl
;
std
::
cout
<<
"inertial force: "
<<
page
.
get_inertial
()
<<
std
::
endl
;
std
::
cout
<<
"Num. steps: "
<<
page
.
get_num_steps
()
<<
std
::
endl
;
for
(
j
=
0
;
j
<
page
.
get_num_steps
();
j
++
)
{
step
=
page
.
get_step
(
j
);
std
::
cout
<<
"angles: "
;
angles
=
step
.
get_angles
();
for
(
k
=
0
;
k
<
angles
.
size
();
k
++
)
std
::
cout
<<
angles
[
k
]
<<
","
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"pausetime: "
<<
step
.
get_pause_time
()
<<
std
::
endl
;
std
::
cout
<<
"step time: "
<<
step
.
get_step_time
()
<<
std
::
endl
;
}
}
for
(
i
=
0
;
i
<
motions
.
get_num_servos
();
i
++
)
motions
.
set_motor_type
(
i
,
servo_type
);
source
.
load_motions
(
motions
);
source
.
generate_src_file
(
std
::
string
(
argv
[
2
]));
}
catch
(
CMtnException
&
e
){
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
}
for
(
i
=
0
;
i
<
motions
.
get_num_servos
();
i
++
)
motions
.
set_motor_type
(
i
,
servo_type
);
source
.
load_motions
(
motions
);
source
.
generate_src_file
(
std
::
string
(
argv
[
2
]));
return
(
EXIT_SUCCESS
);
}
...
...
This diff is collapsed.
Click to expand it.
src/stm32_src_mtn.cpp
+
12
−
7
View file @
fe6b475e
...
...
@@ -65,16 +65,18 @@ void CSTM32SrcMtn::write_word_vector(std::ofstream &file,const std::vector<unsig
file
<<
std
::
endl
;
}
unsigned
char
CSTM32SrcMtn
::
compute_checksum
(
CRobotisPage
&
page
)
unsigned
char
CSTM32SrcMtn
::
compute_checksum
(
int
page
_id
)
{
std
::
vector
<
unsigned
short
int
>
angles
;
std
::
vector
<
unsigned
char
>
cw_compliance
;
std
::
vector
<
unsigned
char
>
ccw_compliance
;
unsigned
char
checksum
=
0x00
;
unsigned
int
i
=
0
,
j
=
0
;
CRobotisPage
page
;
CRobotisStep
step
;
std
::
string
name
;
page
=
this
->
motions
.
get_page
(
page_id
);
name
=
page
.
get_name
();
for
(
i
=
0
;
i
<
14
;
i
++
)
{
...
...
@@ -84,6 +86,7 @@ unsigned char CSTM32SrcMtn::compute_checksum(CRobotisPage &page)
checksum
+=
' '
;
}
checksum
+=
(
unsigned
char
)
page
.
get_repetitions
();
checksum
+=
0x0A
;
checksum
+=
(
unsigned
char
)
page
.
get_num_steps
();
checksum
+=
(
unsigned
char
)
page
.
get_speed_rate
()
*
32
;
checksum
+=
(
unsigned
char
)
page
.
get_inertial
();
...
...
@@ -98,16 +101,15 @@ unsigned char CSTM32SrcMtn::compute_checksum(CRobotisPage &page)
for
(
i
=
0
;
i
<
page
.
get_num_steps
();
i
++
)
{
step
=
page
.
get_step
(
i
);
angles
=
step
.
get_angles
();
for
(
j
=
0
;
j
<
angles
.
size
();
j
++
)
for
(
j
=
0
;
j
<
motions
.
get_num_servos
();
j
++
)
{
checksum
+=
(
unsigned
char
)
angles
[
i
]
&
0x00FF
;
checksum
+=
(
unsigned
char
)(
angles
[
i
]
/
256
)
&
0x00FF
;
checksum
+=
(
unsigned
char
)
(
motions
.
get_angle
(
j
,
page_id
,
i
)
*
128
)
&
0x00FF
;
checksum
+=
(
unsigned
char
)(
((
unsigned
short
)(
motions
.
get_angle
(
j
,
page_id
,
i
)
*
128
))
>>
8
)
&
0x00FF
;
}
checksum
+=
(
unsigned
char
)(
step
.
get_pause_time
()
/
0.0078
);
checksum
+=
(
unsigned
char
)(
step
.
get_step_time
()
/
0.0078
);
}
return
checksum
;
return
256
-
checksum
;
}
void
CSTM32SrcMtn
::
load_motions
(
CRobotisMtn
&
motions
)
...
...
@@ -158,7 +160,10 @@ void CSTM32SrcMtn::generate_src_file(const std::string &filename)
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
1
,
page
.
get_next_page
()),
3
);
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
1
,
page
.
get_exit_page
()),
3
);
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
4
,
0
),
3
);
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
1
,
this
->
compute_checksum
(
page
)),
3
);
if
(
i
==
0
)
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
1
,
0
),
3
);
else
this
->
write_byte_vector
(
file
,
std
::
vector
<
unsigned
char
>
(
1
,
this
->
compute_checksum
(
i
-
1
)),
3
);
byte_vector
.
clear
();
byte_vector
.
resize
(
PAGE_MAX_NUM_SERVOS
);
for
(
j
=
0
;
j
<
page
.
get_cw_compliances
().
size
();
j
++
)
...
...
This diff is collapsed.
Click to expand it.
src/stm32_src_mtn.h
+
1
−
1
View file @
fe6b475e
...
...
@@ -10,7 +10,7 @@ class CSTM32SrcMtn
CRobotisMtn
motions
;
void
write_byte_vector
(
std
::
ofstream
&
file
,
const
std
::
vector
<
unsigned
char
>
&
vector
,
unsigned
int
level
=
0
,
bool
last
=
false
);
void
write_word_vector
(
std
::
ofstream
&
file
,
const
std
::
vector
<
unsigned
short
int
>
&
vector
,
unsigned
int
level
=
0
,
bool
last
=
false
);
unsigned
char
compute_checksum
(
CRobotisPage
&
page
);
unsigned
char
compute_checksum
(
int
page
_id
);
public:
CSTM32SrcMtn
();
void
load_motions
(
CRobotisMtn
&
motions
);
...
...
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