roboticslab-uc3m / yarp-devices

A place for YARP devices
https://robots.uc3m.es/yarp-devices/
9 stars 7 forks source link

adaptation of the new hand board #172

Closed jgvictores closed 6 years ago

jgvictores commented 6 years ago

From @jmgarciah on March 13, 2018 10:2

Once the PCB for the hand is developed. It is necessary to adapt the old code of the PIC to the new MBED.

Copied from original issue: roboticslab-uc3m/teo-hardware-issues#19

rsantos88 commented 6 years ago

The first step is to check the communications between the MBED and the computer. I am trying to send or receive messages over the CAN. Steps taken until now:

Ticker ticker; Serial pc(USBTX, USBRX); // Serial connection DigitalOut live_led(LED4); // CAN read toggle led (activity) DigitalOut led1(LED1); // sended DigitalOut led2(LED2); // received CAN can(p30, p29); // tx,rx char counter = 0;

void liveled() // Toggles the led { live_led=!live_led; }

void send() { printf("send()\n"); // create the message CANMessage messageOut;

messageOut.format = CANStandard; // or  CANExtended; standard or extended ID (can be skipped for standard)
messageOut.id = 10;
messageOut.len = 1; // length in bytes (1 to 8);
messageOut.data[0] = counter; // repeat for each byte.    

// send the message   
if(can.write(messageOut)) {        
    printf("Message sent: %d\n", messageOut.data[0]);    
}    

counter++;    
led1 = !led1;

}

void receive() { CANMessage msg; if(can.read(msg)) { pc.printf("Message received: %d\n", msg.data[0]); led2 = !led2; } }

int main() { pc.baud(115200); // configure PC baudrate for USB pc.printf("main()\n");
// set up the can bus can.frequency(1000000); // 1Mbit/s (the same as the drivers configuration) can.reset();
ticker.attach(&liveled, 1); // Send every 1 sec (to know that the mbed is running at this point) while(1) { send(); wait(0.2);
} }



With this program we can send packets every 200ms and with `dumpCanBus` running on manipulation-pc we should see the messages sent but there is no message captured .
* In other way, you can modify easily the code to call the `receive()` function within the loop instead `send()` function and do the same process but running `launchManipulation` on manipulation computer and receiving some can message through `mbed`. To verify this, I've connected the `mbed` by USB to my computer to monitoring the arrived messages using a serial connection program like [moserial](https://wiki.gnome.org/moserial) but no messages received over the `mbed`.
rsantos88 commented 6 years ago

The mbed firmware for the lacqueyFetch is finished, documented and working: MBED firmware: https://os.mbed.com/users/raulsr988/code/LacqueyFetch/ PR of yarp-devices changes: https://github.com/roboticslab-uc3m/yarp-devices/pull/179

rsantos88 commented 6 years ago

Firmware compatible with the actual ''yarp-devices'' code. Not necessary to do PR. changes: https://os.mbed.com/users/raulsr988/code/LacqueyFetch/rev/8ebb11ba21be/

jgvictores commented 6 years ago

Cool, thanks a lot!

Feel free to close this issue.

jgvictores commented 6 years ago

PS: Copied https://os.mbed.com/users/raulsr988/code/LacqueyFetch/file/8ebb11ba21be/main.cpp to yarp-devices/firmware/LacqueyFetch/main.cpp.