{"action":"created","issue":{"url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/23","repository_url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino","labels_url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/23/comments","events_url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/23/events","html_url":"https://github.com/ROBOTIS-GIT/Dynamixel2Arduino/issues/23","id":506330623,"node_id":"MDU6SXNzdWU1MDYzMzA2MjM=","number":23,"title":"Wishlist: As I am converting from using Dynamixel SDK...","user":{"login":"KurtE","id":1558080,"node_id":"MDQ6VXNlcjE1NTgwODA=","avatar_url":"https://avatars0.githubusercontent.com/u/1558080?v=4","gravatar_id":"","url":"https://api.github.com/users/KurtE","html_url":"https://github.com/KurtE","followers_url":"https://api.github.com/users/KurtE/followers","following_url":"https://api.github.com/users/KurtE/following{/other_user}","gists_url":"https://api.github.com/users/KurtE/gists{/gist_id}","starred_url":"https://api.github.com/users/KurtE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KurtE/subscriptions","organizations_url":"https://api.github.com/users/KurtE/orgs","repos_url":"https://api.github.com/users/KurtE/repos","events_url":"https://api.github.com/users/KurtE/events{/privacy}","received_events_url":"https://api.github.com/users/KurtE/received_events","type":"User","site_admin":false},"labels":[{"id":1341553031,"node_id":"MDU6TGFiZWwxMzQxNTUzMDMx","url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/labels/enhancement","name":"enhancement","color":"a2eeef","default":true,"description":"New feature or request"}],"state":"open","locked":false,"assignee":{"login":"OpusK","id":18085958,"node_id":"MDQ6VXNlcjE4MDg1OTU4","avatar_url":"https://avatars3.githubusercontent.com/u/18085958?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusK","html_url":"https://github.com/OpusK","followers_url":"https://api.github.com/users/OpusK/followers","following_url":"https://api.github.com/users/OpusK/following{/other_user}","gists_url":"https://api.github.com/users/OpusK/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusK/subscriptions","organizations_url":"https://api.github.com/users/OpusK/orgs","repos_url":"https://api.github.com/users/OpusK/repos","events_url":"https://api.github.com/users/OpusK/events{/privacy}","received_events_url":"https://api.github.com/users/OpusK/received_events","type":"User","site_admin":false},"assignees":[{"login":"OpusK","id":18085958,"node_id":"MDQ6VXNlcjE4MDg1OTU4","avatar_url":"https://avatars3.githubusercontent.com/u/18085958?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusK","html_url":"https://github.com/OpusK","followers_url":"https://api.github.com/users/OpusK/followers","following_url":"https://api.github.com/users/OpusK/following{/other_user}","gists_url":"https://api.github.com/users/OpusK/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusK/subscriptions","organizations_url":"https://api.github.com/users/OpusK/orgs","repos_url":"https://api.github.com/users/OpusK/repos","events_url":"https://api.github.com/users/OpusK/events{/privacy}","received_events_url":"https://api.github.com/users/OpusK/received_events","type":"User","site_admin":false}],"milestone":null,"comments":55,"created_at":"2019-10-13T14:12:21Z","updated_at":"2019-11-26T05:11:31Z","closed_at":null,"author_association":"NONE","body":"Hi @OpusK,\r\n\r\nI am trying to get myself going again on the updating of some of Hexapod code base, to now use this library instead of Dynamixel SDK.  The main board that I believe Trossen Robotics will use, is the OpenCM9.04... But I would also for my own usage like for it to work well with Teensy boards by PJRC (with my own carrier boards).   As I do some of this conversions, I run into different things and or wish things were ...  So not sure if this is best place to ask/mention these.   Would you prefer that each by separate, so can easily close off as answered?  \r\n\r\nSo far some of the things I have seen include:\r\n\r\na) Wish more (all) of the examples had more complete options for different boards.  Example the scan_dynamixel sketch does not have any example of how to configure up to run on OpenCM or OpenCR boards.  I did see OpenCM stuff in read_write_ControlTableItem.ino.\r\n\r\nb) Wish you would automatically handle somethings like:\r\n\r\n` #define DXL_SERIAL   Serial3 //OpenCM9.04 EXP Board's DXL port Serial. (To use the DXL port on the OpenCM 9.04 board, you must use Serial1 for Serial. And because of the OpenCM 9.04 driver code, you must call Serial1.setDxlMode(true); before dxl.begin();.)`\r\n\r\nThat is maybe on first call to dxl.begin() if compiled for OpenCM and Serial port is Serial1, do the setDXLMode(True)... Or could test again pin 28 in this case...\r\n\r\nc) Wishing for some of the member functions including some of the constructors, you allowed pass by pointer as well as by reference.  Including ones like:\r\n1) Master::setPort  - I may have a set of ports in an arry so may want to do something like: dxl.setPort( with a pointer to port object)... Will see how hard to get arround.  \r\nInteresting you have a getPort which returns a pointer, but not a way to then use it to set it back... \r\nNot sure if this would work or not:\r\n```\r\nPortHandler *previous_port = dxl.getPort();\r\ndxl.setPort(my_port);\r\n...\r\ndxl.setPort(*previous_port);\r\n\r\n```\r\n\r\n2) SerialPortHandler::SerialPorthandler - WIsh I could pass in HardwareSerial port by pointer...)\r\n\r\n3) Dynamixel2Arduino::Dynamixel2Arduino - maybe should allow to pass in port by address and default to nullptr?   If I going to setup more than one HardwareSerial objects to pass in a different times, then maybe should be able to initially just be able to declare the main object like:\r\nDynamixel2Arduino dxl;\r\n\r\nAnd when I am ready to use it do something like: \r\n`dxl.setPort(port_list[index_port_list]);`\r\n\r\n4) Wish there was easy way to setup to do other forms of SerialPortHandler (subclass?) That is the current version assumes you are using RX, TX and direction pin... But for example with Teensy, I may wish to either use direction pin, in that case I can tell the SerialPort to handle it for me, or I may wish to use half duplex mode (TX Pin), in which case I need to setup in init and set a register bit for which direction I am going ...  \r\n\r\nLikewise for AVR boards, like Trossen Robotics has the Arbotix boards, which don't use a buffer chip or the like but again toggle states of enable RX or TX pin depending on direction.   Obviously I think I could write my own full subclass of the port object to handle this for me, or wonder if ether some of this  should be built into default SerialPortHandler and/or setup to easily sub-class...\r\n\r\nd) keywords.txt needs a pass through to update with all of the member names like:\r\nsetPortProtocolVersionUsingIndex\r\n\r\nThat is all for now... \r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/comments/558462988","html_url":"https://github.com/ROBOTIS-GIT/Dynamixel2Arduino/issues/23#issuecomment-558462988","issue_url":"https://api.github.com/repos/ROBOTIS-GIT/Dynamixel2Arduino/issues/23","id":558462988,"node_id":"MDEyOklzc3VlQ29tbWVudDU1ODQ2Mjk4OA==","user":{"login":"OpusK","id":18085958,"node_id":"MDQ6VXNlcjE4MDg1OTU4","avatar_url":"https://avatars3.githubusercontent.com/u/18085958?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusK","html_url":"https://github.com/OpusK","followers_url":"https://api.github.com/users/OpusK/followers","following_url":"https://api.github.com/users/OpusK/following{/other_user}","gists_url":"https://api.github.com/users/OpusK/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusK/subscriptions","organizations_url":"https://api.github.com/users/OpusK/orgs","repos_url":"https://api.github.com/users/OpusK/repos","events_url":"https://api.github.com/users/OpusK/events{/privacy}","received_events_url":"https://api.github.com/users/OpusK/received_events","type":"User","site_admin":false},"created_at":"2019-11-26T05:11:31Z","updated_at":"2019-11-26T05:11:31Z","author_association":"MEMBER","body":"@KurtE \r\n\r\nI created and used an API to change the buffer as shown below, but in the end, it seemed better to manage it as a separate class to support querying on received data. (Changing the buffer, there was no problem communicating.)\r\n\r\n```cpp\r\ntypedef struct InfoSyncBulkInst{\r\n  uint8_t* p_packet_buf;\r\n  uint16_t packet_buf_capacity;\r\n  uint16_t packet_length;\r\n  uint8_t id_cnt;\r\n  bool is_complete_packet;\r\n  uint16_t addr_len;\r\n} InfoSyncBulkInst_t;\r\n\r\nbool beginSyncRead(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info = nullptr);\r\nbool addSyncReadID(uint8_t id, InfoSyncBulkInst_t *p_sync_info = nullptr, bool flag_end_add = false);\r\nuint16_t sendSyncRead(uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBulkInst_t *p_sync_info = nullptr);\r\n\r\n\r\nbool beginSyncWrite(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info = nullptr);\r\nbool addSyncWriteData(uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync_info = nullptr, bool flag_end_add = false);\r\nbool sendSyncWrite(InfoSyncBulkInst_t *p_sync_info = nullptr);\r\n```\r\n\r\nBelow is a simple example.\r\nOf course, I'm still looking for a better way.\r\n\r\n```cpp\r\n#include <Dynamixel2Arduino.h>\r\n\r\n// Please modify it to suit your hardware.\r\n#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560) // When using DynamixelShield\r\n  #include <SoftwareSerial.h>\r\n  SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX\r\n  #define DXL_SERIAL   Serial\r\n  #define DEBUG_SERIAL soft_serial\r\n  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN\r\n#elif ARDUINO_OpenCM904 // Official ROBOTIS board with DXL circuit.\r\n  #define DXL_SERIAL   Serial3 //OpenCM9.04 EXP Board's DXL port Serial. (Serial1 for the DXL port on the OpenCM 9.04 board)\r\n  #define DEBUG_SERIAL Serial\r\n  const uint8_t DXL_DIR_PIN = 22; //OpenCM9.04 EXP Board's DIR PIN. (28 for the DXL port on the OpenCM 9.04 board)\r\n#elif ARDUINO_OpenCR // Official ROBOTIS board with DXL circuit.\r\n  // For OpenCR, there is a DXL Power Enable pin, so you must initialize and control it.\r\n  // Reference link : https://github.com/ROBOTIS-GIT/OpenCR/blob/master/arduino/opencr_arduino/opencr/libraries/DynamixelSDK/src/dynamixel_sdk/port_handler_arduino.cpp#L78\r\n  #define DXL_SERIAL   Serial3\r\n  #define DEBUG_SERIAL Serial\r\n  const uint8_t DXL_DIR_PIN = 84; // OpenCR Board's DIR PIN.    \r\n#else // When using DynamixelShield\r\n  #define DXL_SERIAL   Serial1\r\n  #define DEBUG_SERIAL Serial\r\n  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN\r\n#endif\r\n\r\n/* InfoSyncBulkInst_t\r\n  A structure that contains the information needed for the parameters of the 'Sync/Bulk Read/Write packet'.\r\n\r\ntypedef struct InfoSyncBulkInst{\r\n  uint8_t* p_packet_buf;\r\n  uint16_t packet_buf_capacity;\r\n  uint16_t packet_length;\r\n  uint8_t id_cnt;\r\n  bool is_complete_packet;\r\n} InfoSyncBulkInst_t;\r\n*/\r\n\r\nDYNAMIXEL::InfoSyncBulkInst_t sr_present_pos;\r\nconst uint16_t user_pkt_buf_cap = 128;\r\nuint8_t user_pkt_buf[user_pkt_buf_cap];\r\nconst uint16_t recv_buf_cap = 128;\r\nuint8_t recv_buf[recv_buf_cap];\r\nint32_t goal_vel = 0;\r\n\r\nDynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);\r\n\r\nvoid setup() {\r\n  // put your setup code here, to run once:\r\n  DEBUG_SERIAL.begin(115200);\r\n  dxl.begin(1000000);\r\n  dxl.scan();\r\n  \r\n  dxl.torqueOff(1);\r\n  dxl.setOperatingMode(1, OP_VELOCITY);\r\n  dxl.torqueOn(1);\r\n\r\n  dxl.torqueOff(3);\r\n  dxl.setOperatingMode(3, OP_VELOCITY);\r\n  dxl.torqueOn(3);\r\n\r\n  // Using user buffer\r\n  sr_present_pos.p_packet_buf = user_pkt_buf;\r\n  sr_present_pos.packet_buf_capacity = user_pkt_buf_cap;\r\n\r\n  dxl.beginSyncRead(132, 4, &sr_present_pos);\r\n  dxl.addSyncReadID(1, &sr_present_pos);\r\n  dxl.addSyncReadID(3, &sr_present_pos, true);\r\n\r\n  // Using class default buffer\r\n  dxl.beginSyncWrite(104, 4);\r\n  goal_vel = 100;\r\n  dxl.addSyncWriteData(1, (uint8_t*)&goal_vel);\r\n  goal_vel = 200;\r\n  dxl.addSyncWriteData(3, (uint8_t*)&goal_vel);\r\n  dxl.sendSyncWrite();\r\n}\r\n\r\nvoid loop() {\r\n  // put your main code here, to run repeatedly:\r\n  uint16_t recv_len;\r\n  \r\n  recv_len = dxl.sendSyncRead(recv_buf, recv_buf_cap, &sr_present_pos);\r\n  if(recv_len > 0){\r\n    DEBUG_SERIAL.print(\"\\t Receive Len : \");\r\n    DEBUG_SERIAL.print(recv_len);\r\n    DEBUG_SERIAL.println();\r\n    for(uint16_t i=0; i<recv_len; i++){\r\n      DEBUG_SERIAL.print(recv_buf[i], HEX);DEBUG_SERIAL.print(\" \");\r\n    }\r\n    DEBUG_SERIAL.println();\r\n  }else{\r\n    DEBUG_SERIAL.print(\"\\t Fail!!   \");\r\n    DEBUG_SERIAL.print(dxl.getLastLibErrCode());\r\n    DEBUG_SERIAL.println();\r\n  }\r\n  delay(500);\r\n}\r\n```\r\nhttps://github.com/ROBOTIS-GIT/Dynamixel2Arduino/blob/code_layer_redesign/examples/advanced/sync_read_write_raw/sync_read_write_raw.ino"}}
{"actor":{"display_login":"OpusK"}}