guzhaoyuan / epos2

ros node, communication with python, control epos2 50/5 for maxon
6 stars 5 forks source link
epos2 maxon ros

epos2

maxon DC motor current control, communicate with rospy

Protocal

Torque.srv

float64 position # used as step counter
float64 torque
int16 init # if true, the controller random init a state
---
float64[3] state_new # cos() sin() velocity
float64 reward #used
bool done # used
float64 velocity # not used, calc by differenciate position
float64 position_new #-pi to pi, now not used
float64 current # not used

EPOS2 info

using USB mode, no need to set baudrate

for EPOS2 setup for linux, see docs/EPOS Command Library.pdf

for driver and library, find 'EPOS_Linux_Library' on maxon official site(https://www.maxonmotorusa.com/maxon/view/product/control/Positionierung/347717)

Framework

node1: request position or torque, calculate on return

node2: receive request and execute, wait until end of this step, return new state and info, then wait for new request

Files

src

controller.cpp: node for controlling torque, also work as env

test_epos2.cpp: test for develop wrap.cpp: wrap api to make code clean and easy to program time_test.cpp: test time

position_server.cpp: create service to control postion current_server.cpp: create service to control current velocity_server.cpp: create service to control velocity

scripts

agent,py: request torque, also works as rl agent

request.py: node for requesting service and get info from controller, now backup, not for use

position_client.py: request position control service current_client.py: request current control service velocity_client.py: request velocity control service

include

headings

Usages

use as a ros package, put the whole epos2 files under workspace/src and compile with catkin

#under ${workspace}
catkin_make
rosrun epos2 current_server
rosrun epos2 current_client.py

Benchmark

time taken:

now strategy: get position 5ms, calculate velocity based on position, get request & return reward 7ms, rl get action <=3ms, rl update & pull <=4ms

controlling cycle: 30ms, 33.3Hz