According to the docs for the Term object the ID is in the property term_id
So you need:
$ids = array();
foreach ($taxonomy as $tax) {
$ids[] = $tax->term_id;
}
$joinedIds = implode(" ", $ids);
// do something with $joinedIds;