Hacks4ROS / h4r_ev3_ctrl

ROS Node for managing EV3 with ROS Control
GNU General Public License v3.0
21 stars 12 forks source link

controlling motors and using multiple sensors #2

Closed inhok996 closed 8 years ago

inhok996 commented 8 years ago

Hello again!

I've tried to operate your pkgs and I have a couple of questions.

I roslaunched ultrasonic.launch, motor.launch successfully but I have a problem with using topics.

I could manage to subscribe the topic "/ultrasonic" but I don't know how to publish topic "/ev3dev/OutportA/command"

I googled for days but I still no have idea to make the motors work.

I found the type of topic "command" is "std_msg/Float64".

Q1) Does that mean I should publish just velocity of motors??? or something more than that?

Because topic "joint_states" publishes multiple values, I don't think I should publish just velocity of motors.

Please give me a hint or show me your source code of publisher node (the one used on your Youtube demo) if you are ok..

Q2) Can I launch multiple sensors??

Because I launched ultrasonic sensor and again launched color sensor and the formal one died..

I'm gonna try to modify launch files but before that, I want to ask you about it first.

Thanks a lot.


My topic lists are below

Published topics:

Subscribed topics:

inhok996 commented 8 years ago

I tried to rostopic pub /ev3dev/OutPortA/command std_msgs/Float64 5.0 but nothing happend

cyborg-x1 commented 8 years ago

rostopic pub /ev3dev/OutPortA/command std_msgs/Float64 "data: 5.0" Should actually do the trick to make it turn.

inhok996 commented 8 years ago

I tired once again. but the same.. the motor doesn't work.

I unpluged cables of motors from my ev3 brick and tried

roslaunch h4r_ev3_launch motor.launch

but no error occurred and it seemed that all controllers of the motors loaded successfully. ( when I tried to do the same thing in ultrasonic sensor, some errors occurred and I had to pluged in the cable of ultrasonic sensor to exactly "in2" / This is specified in ultrasonic.yaml )

So I wonder if the controllers work properly.

Can you check this out?..

ps) I checked motors working when I ev3_ev3dev-lang demo.


root@ev3dev:~# ev3_manager getFilePTR opening: /sys/class/tacho-motor/motor3/position 0x66390 getFilePTR opening: /sys/class/tacho-motor/motor3/speed 0x681b8 getFilePTR opening: /sys/class/tacho-motor/motor2/position 0x68320 getFilePTR opening: /sys/class/tacho-motor/motor2/speed 0x66710

inho@ubuntu:~/catkin_ws/src/beginner_tutorials$ roslaunch h4r_ev3_launch motors.launch ... logging to /home/inho/.ros/log/07ca6d4a-05ed-11e6-9c4e-000c2944140a/roslaunch-ubuntu-6170.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:34882/

SUMMARY

PARAMETERS

NODES /ev3dev/ controller_spawner (controller_manager/spawner) ev3_manager_node (h4r_ev3_manager/ev3_manager_node)

ROS_MASTER_URI=http://localhost:11311

core service [/rosout] found process[ev3dev/ev3_manager_node-1]: started with pid [6188] process[ev3dev/controller_spawner-2]: started with pid [6189] [INFO] [WallTime: 1461042642.402335] Controller Spawner: Waiting for service controller_manager/load_controller [INFO] [WallTime: 1461042642.408167] Controller Spawner: Waiting for service controller_manager/switch_controller [INFO] [WallTime: 1461042642.411062] Controller Spawner: Waiting for service controller_manager/unload_controller [INFO] [WallTime: 1461042642.419903] Loading controller: OutPortState [INFO] [WallTime: 1461042642.553937] Loading controller: OutPortA [INFO] [WallTime: 1461042642.647706] Loading controller: OutPortB [INFO] [WallTime: 1461042642.753752] Controller Spawner: Loaded controllers: OutPortState, OutPortA, OutPortB [ INFO] [1461042642.763800006]: Controller Change [ INFO] [1461042642.765381678]: velocity_controllers/JointVelocityController requests Joint OutPortA Joint_A [ INFO] [1461042642.777606933]: <--------------EV3 Joint Joint_A----------------> [ INFO] [1461042642.792417002]: Joint control mode: velocity [ INFO] [1461042642.802080273]: P: 1001 I: 61 D: 1 [ INFO] [1461042642.802165909]: </-------------EV3 Joint Joint_A---------------->

[ INFO] [1461042642.802864933]: PID 1001 61 1 [ INFO] [1461042642.803315802]: velocity_controllers/JointVelocityController requests Joint OutPortB Joint_B [ INFO] [1461042642.807096057]: <--------------EV3 Joint Joint_B----------------> [ INFO] [1461042642.808576030]: Joint control mode: velocity [ INFO] [1461042642.811388622]: P: 1002 I: 62 D: 2 [ INFO] [1461042642.811543573]: </-------------EV3 Joint Joint_B---------------->

[ INFO] [1461042642.812131619]: PID 1002 62 2 [INFO] [WallTime: 1461042642.847636] Started controllers: OutPortState, OutPortA, OutPortB

inhok996 commented 8 years ago

my ev3 motors now work. I found out that motor.launch should be launched on ev3dev because the device files of motors and sensors are located in ev3dev file system and ev3_manager node only can be associated with the files in ev3dev if I'm right.

Because I "roslaunch motor.launch" in host linux(the one where I run roscore), I prevented running ev3_manager_node from motor.launch by deleting two lines about it. I use ev3_manager in yocto ev3dev instead.

cyborg-x1 commented 8 years ago

Ah - you launched it on your PC... Well it would work if you build serial adapters for your PC and compile and install the drivers...

inhok996 commented 8 years ago

Oh! That is good tip for me. Thank you so much.