Skip to content
GitLab
Explore
Sign in
Victor
Rosserial VarSpeedServos
Compare revisions
8e8d965f3f92ed1d3ddca6bab86fd38140976159 to ff21bfcf0e9a494dec45630160fe0abc3977df70
Commits on Source (2)
remove obsolete file
· 7fed9a2a
Victor
authored
Oct 08, 2022
7fed9a2a
add link to dependencies (to be downloaded to the library folder)
· ff21bfcf
Victor
authored
Oct 08, 2022
ff21bfcf
Hide whitespace changes
Inline
Side-by-side
SERVOS_ROS.ino
deleted
100644 → 0
View file @
8e8d965f
/****************************************************************************
* Author : Victor Dubois
****************************************************************************/
#include
<ros.h>
#include
<goal_strategy/servos_cmd.h>
#include
<VarSpeedServo.h>
#define BRAK 0
#define BRAK_PIN 10//Todo check
#define PAVILLON 1
#define PAVILLON_PIN 11//Todo check
#define NB_SERVOS 2
ros
::
NodeHandle
nh
;
VarSpeedServo
myServos
[
NB_SERVOS
];
bool
stopped
=
true
;
void
cmd_servos_cb
(
const
goal_strategy
::
servos_cmd
&
command
)
{
if
(
!
command
.
enable
)
{
if
(
!
stopped
)
{
for
(
int
i
=
0
;
i
<
NB_SERVOS
;
i
++
)
{
myServos
[
i
].
detach
();
}
}
stopped
=
true
;
return
;
}
if
(
stopped
)
{
stopped
=
false
;
myServos
[
BRAK
].
attach
(
BRAK_PIN
);
myServos
[
PAVILLON
].
attach
(
PAVILLON_PIN
);
}
myServos
[
BRAK
].
write
(
command
.
brak_speed
,
command
.
brak_angle
,
false
);
myServos
[
PAVILLON
].
write
(
command
.
pavillon_speed
,
command
.
pavillon_angle
,
false
);
}
ros
::
Subscriber
<
goal_strategy
::
servos_cmd
>
servos_cmd_sub
(
"cmd_servos"
,
cmd_servos_cb
);
void
setup
()
{
pinMode
(
BRAK_PIN
,
OUTPUT
);
pinMode
(
PAVILLON_PIN
,
OUTPUT
);
nh
.
initNode
();
nh
.
subscribe
(
servos_cmd_sub
);
}
void
loop
()
{
nh
.
spinOnce
();
delay
(
50
);
}
SERVOS_ROS/SERVOS_ROS.ino
View file @
ff21bfcf
...
...
@@ -9,8 +9,8 @@
#include
<std_msgs/Float32.h>
#include
<Wire.h>
#include
<LiquidCrystal_I2C.h>
#include
<VarSpeedServo.h>
#include
<LiquidCrystal_I2C.h>
// https://github.com/johnrickman/LiquidCrystal_I2C
#include
<VarSpeedServo.h>
// https://github.com/netlabtoolkit/VarSpeedServo
#define BASE_SERVO 0
#define BASE_SERVO_PIN 9
...
...