Gazebo | Ignition | Community
Ask Your Question
0

Capture key press with a Gazebo plugin

asked 2018-04-25 04:19:55 -0500

VansFannel gravatar image

updated 2018-04-26 11:42:32 -0500

I'm new in Gazebo and I want to control a robot with the keyboard writing my own plugin.

I have found how to move the model, following this tutorial: http://gazebosim.org/tutorials?tut=pl...

I think is using this code:

this->model->SetLinearVel(ignition::math::Vector3d(.3, 0, 0));

But I don't know how when a key has been pressed and released.

How can I get those events in a plugin?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-20 03:13:52 -0500

AlberSaber gravatar image

updated 2018-11-20 11:56:52 -0500

chapulina gravatar image

Good morning , me too i search the thing but i found an example that control the joints by kyes from key board

1- First you will use this 2 plugins :

KeyboardGUIPlugin, KeysToJointsPlugin from :

https://bitbucket.org/osrf/gazebo/src...

https://bitbucket.org/osrf/gazebo/src...

https://bitbucket.org/osrf/gazebo/src...

https://bitbucket.org/osrf/gazebo/src...

2- The world file :

https://bitbucket.org/osrf/gazebo/src...

3- The CMakeLists.txt as :

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package (Qt5Core REQUIRED)
find_package (Qt5Widgets REQUIRED)
set (CMAKE_AUTOMOC ON)

find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

add_library(KeyboardGUIPlugin MODULE KeyboardGUIPlugin.cc)
target_link_libraries(KeyboardGUIPlugin ${GAZEBO_LIBRARIES} Qt5::Core)

add_library(KeysToJointsPlugin MODULE KeysToJointsPlugin.cc)
target_link_libraries(KeysToJointsPlugin ${GAZEBO_LIBRARIES} Qt5::Core)

4- then run it :

mkdir build
cd build
cmake ../
make
export GAZEBO_PLUGIN_PATH=`pwd`:$GAZEBO_PLUGIN_PATH
gazebo -u --verbose ../simple_arm_teleop.world

test keys 6, y, h, u, j, i, k :)

Did you found anything helpfull ? tahnks

edit flag offensive delete link more

Comments

Yes, I'm doing it using ROS because it is easier.

VansFannel gravatar imageVansFannel ( 2018-11-20 12:43:29 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-25 04:19:55 -0500

Seen: 1,465 times

Last updated: Nov 20 '18