Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Simon Markus Haller-Seeber
minibot
Commits
942d6a25
Commit
942d6a25
authored
Aug 25, 2021
by
Matteo Saveriano
Browse files
OImplemented simple readLine() for serial stream
parent
d1040f75
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
catkin_ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.cpp
...ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.cpp
+23
-3
catkin_ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.h
...n_ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.h
+2
-0
No files found.
catkin_ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.cpp
View file @
942d6a25
...
@@ -111,6 +111,22 @@ namespace lss_4dof_hw_interface
...
@@ -111,6 +111,22 @@ namespace lss_4dof_hw_interface
ROS_INFO_STREAM_NAMED
(
name_
,
"Hardware Interface Ready."
);
ROS_INFO_STREAM_NAMED
(
name_
,
"Hardware Interface Ready."
);
}
}
std
::
string
LSS4DOFHWInterface
::
readLine
(
LibSerial
::
SerialStream
sStream
,
char
lineTerminator
)
{
// ToDO Add a timeout
std
::
string
line_
=
""
;
char
nextChar
=
0
;
while
(
nextChar
!=
lineTerminator
)
{
sStream
>>
nextChar
;
line_
+=
nextChar
;
}
return
line_
;
}
void
LSS4DOFHWInterface
::
read
(
ros
::
Duration
&
elapsed_time
)
void
LSS4DOFHWInterface
::
read
(
ros
::
Duration
&
elapsed_time
)
{
{
// ToDo current position from Arm
// ToDo current position from Arm
...
@@ -122,15 +138,19 @@ namespace lss_4dof_hw_interface
...
@@ -122,15 +138,19 @@ namespace lss_4dof_hw_interface
// This should compile with libserial-dev (Version >=1.0. Note: Ubuntu 18.04 uses libserial-dev 0.6)
// This should compile with libserial-dev (Version >=1.0. Note: Ubuntu 18.04 uses libserial-dev 0.6)
// This is an untest code stub just to get going
// This is an untest code stub just to get going
/*
serial
<<
"#0QD"
<<
std
::
endl
;
serial
<<
"#0QD"
<<
std
::
endl
;
myposstr << serial.Readline() ;
//myposstr << serial.Readline() ;
myposstr
=
readLine
(
serial
);
// Diveded by 10 because we get 1/10 degree and converted tor rad
// Diveded by 10 because we get 1/10 degree and converted tor rad
pos_double
=
std
::
stod
(
myposstr
.
substr
(
4
))
/
10
*
(
M_PI
/
180
)
;
pos_double
=
std
::
stod
(
myposstr
.
substr
(
4
))
/
10
*
(
M_PI
/
180
)
;
myposstr
=
""
;
myposstr
=
""
;
joint_position_
.
push_back
(
pos_double
);
joint_position_
.
push_back
(
pos_double
);
serial << "#1QD" << std::endl ;
// For debug
ROS_INFO
(
"First joint angle: %d"
,
pos_double
);
/*serial << "#1QD" << std::endl ;
myposstr << serial.Readline() ;
myposstr << serial.Readline() ;
// Diveded by 10 because we get 1/10 degree and converted tor rad
// Diveded by 10 because we get 1/10 degree and converted tor rad
pos_double = std::stod(myposstr.substr(4))/10*(M_PI/180);
pos_double = std::stod(myposstr.substr(4))/10*(M_PI/180);
...
...
catkin_ws/src/lss_4dof/lss_4dof_hw/src/lss_4dof_hw_interface.h
View file @
942d6a25
...
@@ -96,6 +96,8 @@ namespace lss_4dof_hw_interface
...
@@ -96,6 +96,8 @@ namespace lss_4dof_hw_interface
// Serial connection
// Serial connection
LibSerial
::
SerialStream
serial
;
LibSerial
::
SerialStream
serial
;
std
::
string
readLine
(
LibSerial
::
SerialStream
sStream
,
const
char
lineTerminator
=
"
\n
"
);
protected:
protected:
/** \brief LSS 4DOF interface */
/** \brief LSS 4DOF interface */
LSS4DOFHWInterface
*
lss_4dof
;
LSS4DOFHWInterface
*
lss_4dof
;
...
...
Write
Preview
Markdown
is supported
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