Skip to content

Instantly share code, notes, and snippets.

@naxvm
Created March 13, 2020 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naxvm/bec8e95679dda7942140d3e61da4de04 to your computer and use it in GitHub Desktop.
Save naxvm/bec8e95679dda7942140d3e61da4de04 to your computer and use it in GitHub Desktop.
diff --git a/kobuki_keyop/src/keyop_core.cpp b/kobuki_keyop/src/keyop_core.cpp
index 62cd0c46..9e76ff15 100644
--- a/kobuki_keyop/src/keyop_core.cpp
+++ b/kobuki_keyop/src/keyop_core.cpp
@@ -271,7 +271,7 @@ void KeyOpCore::keyboardInputLoop()
*/
void KeyOpCore::remoteKeyInputReceived(const kobuki_msgs::KeyboardInput& key)
{
- processKeyboardInput(key.pressed_key);
+ processKeyboardInput(key.pressedKey);
}
/**
@@ -290,27 +290,27 @@ void KeyOpCore::processKeyboardInput(char c)
*/
switch (c)
{
- case kobuki_msgs::KeyboardInput::KEYCODE_LEFT:
+ case kobuki_msgs::KeyboardInput::KeyCode_Left:
{
incrementAngularVelocity();
break;
}
- case kobuki_msgs::KeyboardInput::KEYCODE_RIGHT:
+ case kobuki_msgs::KeyboardInput::KeyCode_Right:
{
decrementAngularVelocity();
break;
}
- case kobuki_msgs::KeyboardInput::KEYCODE_UP:
+ case kobuki_msgs::KeyboardInput::KeyCode_Up:
{
incrementLinearVelocity();
break;
}
- case kobuki_msgs::KeyboardInput::KEYCODE_DOWN:
+ case kobuki_msgs::KeyboardInput::KeyCode_Down:
{
decrementLinearVelocity();
break;
}
- case kobuki_msgs::KeyboardInput::KEYCODE_SPACE:
+ case kobuki_msgs::KeyboardInput::KeyCode_Space:
{
resetVelocity();
break;
diff --git a/kobuki_node/src/library/slot_callbacks.cpp b/kobuki_node/src/library/slot_callbacks.cpp
index 21d57788..2c41c266 100644
--- a/kobuki_node/src/library/slot_callbacks.cpp
+++ b/kobuki_node/src/library/slot_callbacks.cpp
@@ -275,9 +275,9 @@ void KobukiRos::publishButtonEvent(const ButtonEvent &event)
default: break;
}
switch(event.button) {
- case(ButtonEvent::Button0) : { msg->button = kobuki_msgs::ButtonEvent::BUTTON0; break; }
- case(ButtonEvent::Button1) : { msg->button = kobuki_msgs::ButtonEvent::BUTTON1; break; }
- case(ButtonEvent::Button2) : { msg->button = kobuki_msgs::ButtonEvent::BUTTON2; break; }
+ case(ButtonEvent::Button0) : { msg->button = kobuki_msgs::ButtonEvent::Button0; break; }
+ case(ButtonEvent::Button1) : { msg->button = kobuki_msgs::ButtonEvent::Button1; break; }
+ case(ButtonEvent::Button2) : { msg->button = kobuki_msgs::ButtonEvent::Button2; break; }
default: break;
}
button_event_publisher.publish(msg);
diff --git a/kobuki_testsuite/scripts/gyro_perf.py b/kobuki_testsuite/scripts/gyro_perf.py
index d2e1eb3f..d5139336 100755
--- a/kobuki_testsuite/scripts/gyro_perf.py
+++ b/kobuki_testsuite/scripts/gyro_perf.py
@@ -254,13 +254,13 @@ class Tester(object):
def buttonCallback(self,data):
if rospy.is_shutdown(): return
- if data.button == ButtonEvent.BUTTON0 and data.state == ButtonEvent.RELEASED:
+ if data.button == ButtonEvent.Button0 and data.state == ButtonEvent.RELEASED:
#if self.debug: print 'button0 pressed'
self.triggered=True
return
- #if data.button == ButtonEvent.BUTTON1 and data.state == ButtonEvent.RELEASED:
+ #if data.button == ButtonEvent.Button1 and data.state == ButtonEvent.RELEASED:
# if self.debug: print 'button1 pressed'; return
- #if data.button == ButtonEvent.BUTTON2 and data.state == ButtonEvent.RELEASED:
+ #if data.button == ButtonEvent.Button2 and data.state == ButtonEvent.RELEASED:
# if self.debug: print 'button2 pressed'; return
if __name__ == '__main__':
diff --git a/kobuki_testsuite/scripts/test_events.py b/kobuki_testsuite/scripts/test_events.py
index 4b6b88bd..fa159467 100755
--- a/kobuki_testsuite/scripts/test_events.py
+++ b/kobuki_testsuite/scripts/test_events.py
@@ -46,10 +46,10 @@ def ButtonEventCallback(data):
if ( data.state == ButtonEvent.RELEASED ) :
state = "released"
else:
- state = "pressed"
- if ( data.button == ButtonEvent.BUTTON0 ) :
+ state = "pressed"
+ if ( data.button == ButtonEvent.Button0 ) :
button = "B0"
- elif ( data.button == ButtonEvent.BUTTON1 ) :
+ elif ( data.button == ButtonEvent.Button1 ) :
button = "B1"
else:
button = "B2"
@@ -59,7 +59,7 @@ def BumperEventCallback(data):
if ( data.state == BumperEvent.RELEASED ) :
state = "released"
else:
- state = "pressed"
+ state = "pressed"
if ( data.bumper == BumperEvent.LEFT ) :
bumper = "Left"
elif ( data.bumper == BumperEvent.CENTER ) :
@@ -67,23 +67,23 @@ def BumperEventCallback(data):
else:
bumper = "Right"
rospy.loginfo("%s bumper is %s."%(bumper, state))
-
+
def WheelDropEventCallback(data):
if ( data.state == WheelDropEvent.RAISED ) :
state = "raised"
else:
- state = "dropped"
+ state = "dropped"
if ( data.wheel == WheelDropEvent.LEFT ) :
wheel = "Left"
else:
wheel = "Right"
rospy.loginfo("%s wheel is %s."%(wheel, state))
-
+
def CliffEventCallback(data):
if ( data.state == CliffEvent.FLOOR ) :
state = "on the floor"
else:
- state = "on the cliff"
+ state = "on the cliff"
if ( data.sensor == CliffEvent.LEFT ) :
cliff = "Left"
elif ( data.sensor == CliffEvent.CENTER ) :
@@ -113,7 +113,7 @@ def InputEventCallback(data):
for val in data.values:
val_str = "%s, %s" % (val_str, str(val))
rospy.loginfo("Digital input values: [" + val_str[2:] + "]")
-
+
rospy.init_node("test_events")
rospy.Subscriber("/mobile_base/events/button",ButtonEvent,ButtonEventCallback)
rospy.Subscriber("/mobile_base/events/bumper",BumperEvent,BumperEventCallback)
@@ -134,4 +134,4 @@ print " - battery low/critical"
print " - digital input changes"
print ""
rospy.spin()
-
+
diff --git a/kobuki_testsuite/scripts/test_input.py b/kobuki_testsuite/scripts/test_input.py
index 0ef12617..8dac7564 100755
--- a/kobuki_testsuite/scripts/test_input.py
+++ b/kobuki_testsuite/scripts/test_input.py
@@ -73,35 +73,35 @@ def DigitalInputEventCallback(data):
global digitalS
digitalS = data.values
-button0 = { ButtonEvent.BUTTON0:0, ButtonEvent.BUTTON1:1, ButtonEvent.BUTTON2:2, }
+button0 = { ButtonEvent.Button0:0, ButtonEvent.Button1:1, ButtonEvent.Button2:2, }
button1 = { ButtonEvent.RELEASED:'Released', ButtonEvent.PRESSED:'Pressed ', }
-buttonS = [ 'Released', 'Released', 'Released', ]
+buttonS = [ 'Released', 'Released', 'Released', ]
def ButtonEventCallback(data):
buttonS[button0[data.button]]=button1[data.state]
-bumper0 = { BumperEvent.LEFT:0, BumperEvent.CENTER:1, BumperEvent.RIGHT:2, }
+bumper0 = { BumperEvent.LEFT:0, BumperEvent.CENTER:1, BumperEvent.RIGHT:2, }
bumper1 = { BumperEvent.RELEASED:'Released', BumperEvent.PRESSED:'Pressed ', }
-bumperS = [ 'Released', 'Released', 'Released', ]
+bumperS = [ 'Released', 'Released', 'Released', ]
def BumperEventCallback(data):
bumperS[bumper0[data.bumper]]=bumper1[data.state]
-wheel0 = { WheelDropEvent.LEFT:0, WheelDropEvent.RIGHT:1, }
+wheel0 = { WheelDropEvent.LEFT:0, WheelDropEvent.RIGHT:1, }
wheel1 = { WheelDropEvent.RAISED:'Raised ', WheelDropEvent.DROPPED:'Dropped', }
-wheelS = [ 'Raised ', 'Raised ', ]
+wheelS = [ 'Raised ', 'Raised ', ]
def WheelDropEventCallback(data):
wheelS[wheel0[data.wheel]]=wheel1[data.state]
-cliff0 = { CliffEvent.LEFT:0, CliffEvent.CENTER:1, CliffEvent.RIGHT:2, }
+cliff0 = { CliffEvent.LEFT:0, CliffEvent.CENTER:1, CliffEvent.RIGHT:2, }
cliff1 = { CliffEvent.FLOOR:'Floor', CliffEvent.CLIFF:'Cliff', }
cliffS = [ 'Floor', 'Floor', 'Floor',]
def CliffEventCallback(data):
cliffS[cliff0[data.sensor]]=cliff1[data.state]
-power0 = {
+power0 = {
PowerSystemEvent.UNPLUGGED:"Robot unplugged",
PowerSystemEvent.PLUGGED_TO_ADAPTER:"Robot plugged to adapter",
PowerSystemEvent.PLUGGED_TO_DOCKBASE:"Robot plugged to docking base",
@@ -118,7 +118,7 @@ def PowerEventCallback(data):
def clearing():
curses.echo()
stdscr.keypad(0)
- curses.endwin()
+ curses.endwin()
if __name__ == '__main__':
@@ -129,7 +129,7 @@ if __name__ == '__main__':
curses.noecho()
stdscr.keypad(1)
stdscr.nodelay(1)
-
+
rospy.init_node('test_input')
rospy.on_shutdown(clearing)
rospy.Subscriber("/mobile_base/sensors/imu_data", Imu, ImuCallback )
@@ -140,7 +140,7 @@ if __name__ == '__main__':
rospy.Subscriber("/mobile_base/events/wheel_drop", WheelDropEvent, WheelDropEventCallback )
rospy.Subscriber("/mobile_base/events/cliff", CliffEvent, CliffEventCallback )
rospy.Subscriber("/mobile_base/events/power_system",PowerSystemEvent,PowerEventCallback)
-
+
try:
while not rospy.is_shutdown():
stdscr.addstr(7,3,str("Digital input: [%5s, %5s, %5s, %5s]"\
@@ -154,8 +154,8 @@ if __name__ == '__main__':
key = stdscr.getch()
if key == ord('q'):
rospy.signal_shutdown('user request')
-
+
clearing()
except:
clearing()
- traceback.print_exc()
+ traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment